Get WF State programmatically

オフライン
Hello all I have a problem to get the state of Workflow of an Item. I can get the state of lifecycle but do not know how to get the WF-State? Any hint which can help me?   Thanks Mahmoud
Parents
  • Hello Mahmoud, If I understand your question now, is how to get active activities (in Aras you can have more that one Active activities) and not the state value of the Workflow? So lets update the code:
    string aml = @"
     <AML>
       <Item type='Workflow' action='get'>
         <source_id>{itemID}</source_id>
         <related_id>
           <Item type='Workflow Process' action='get'>
             <Relationships>
               <Item action='get' type='Workflow Process Activity'>
                 <related_id>
                   <Item type='Activity'>
                     <cloned_as condition='is null' />
                     <state>Active</state>
                   </Item>
                 </related_id>
               </Item>
             </Relationships>
           </Item>
         </related_id>
       </Item>
     </AML>";
    
    Item workflowItem = this.getInnovator().applyAML(aml);
    if (workflowItem != null && !workflowItem.getItemCount() > 0) {
      Item activeActivities = workflowItem.getItemsByXPath("//Item[@type='Activity']");
      for (int i = 0; i < activeActivities.getItemCount(); i++) {
        Item activeActivity = activeActivities.getItemByIndex(i);
        string activeActivityName = activeActivity.getProperty("name", "");
      }
    }
Reply
  • Hello Mahmoud, If I understand your question now, is how to get active activities (in Aras you can have more that one Active activities) and not the state value of the Workflow? So lets update the code:
    string aml = @"
     <AML>
       <Item type='Workflow' action='get'>
         <source_id>{itemID}</source_id>
         <related_id>
           <Item type='Workflow Process' action='get'>
             <Relationships>
               <Item action='get' type='Workflow Process Activity'>
                 <related_id>
                   <Item type='Activity'>
                     <cloned_as condition='is null' />
                     <state>Active</state>
                   </Item>
                 </related_id>
               </Item>
             </Relationships>
           </Item>
         </related_id>
       </Item>
     </AML>";
    
    Item workflowItem = this.getInnovator().applyAML(aml);
    if (workflowItem != null && !workflowItem.getItemCount() > 0) {
      Item activeActivities = workflowItem.getItemsByXPath("//Item[@type='Activity']");
      for (int i = 0; i < activeActivities.getItemCount(); i++) {
        Item activeActivity = activeActivities.getItemByIndex(i);
        string activeActivityName = activeActivity.getProperty("name", "");
      }
    }
Children
No Data