<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.aras.com/community/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Get WF State programmatically</title><link>https://www.aras.com/community/f/development/3504/get-wf-state-programmatically</link><description>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</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Get WF State programmatically</title><link>https://www.aras.com/community/thread/1137?ContentTypeID=1</link><pubDate>Wed, 20 Dec 2017 05:39:34 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:4b054a45-b453-41d2-b781-1e7373f7ad75</guid><dc:creator>Former Member</dc:creator><description>beautiful

It worked :)

thank you&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get WF State programmatically</title><link>https://www.aras.com/community/thread/1138?ContentTypeID=1</link><pubDate>Wed, 20 Dec 2017 04:40:34 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:a6872b43-af71-4a56-8329-bd44a1520c7f</guid><dc:creator>Zahar Chernov</dc:creator><description>Hello Mahmoud,

If I understand your question now, is how to get &lt;strong&gt;active&lt;/strong&gt; activities (in Aras you can have more that one Active activities) and not the state value of the Workflow?

So lets update the code:
&lt;blockquote&gt;
&lt;pre&gt;string aml = @&amp;quot;
 &amp;lt;AML&amp;gt;
   &amp;lt;Item type=&amp;#39;Workflow&amp;#39; action=&amp;#39;get&amp;#39;&amp;gt;
     &amp;lt;source_id&amp;gt;{itemID}&amp;lt;/source_id&amp;gt;
     &amp;lt;related_id&amp;gt;
       &amp;lt;Item type=&amp;#39;Workflow Process&amp;#39; action=&amp;#39;get&amp;#39;&amp;gt;
         &amp;lt;Relationships&amp;gt;
           &amp;lt;Item action=&amp;#39;get&amp;#39; type=&amp;#39;Workflow Process Activity&amp;#39;&amp;gt;
             &amp;lt;related_id&amp;gt;
               &amp;lt;Item type=&amp;#39;Activity&amp;#39;&amp;gt;
                 &amp;lt;cloned_as condition=&amp;#39;is null&amp;#39; /&amp;gt;
                 &amp;lt;state&amp;gt;Active&amp;lt;/state&amp;gt;
               &amp;lt;/Item&amp;gt;
             &amp;lt;/related_id&amp;gt;
           &amp;lt;/Item&amp;gt;
         &amp;lt;/Relationships&amp;gt;
       &amp;lt;/Item&amp;gt;
     &amp;lt;/related_id&amp;gt;
   &amp;lt;/Item&amp;gt;
 &amp;lt;/AML&amp;gt;&amp;quot;;

Item workflowItem = this.getInnovator().applyAML(aml);
if (workflowItem != null &amp;amp;&amp;amp; !workflowItem.getItemCount() &amp;gt; 0) {
  Item activeActivities = workflowItem.getItemsByXPath(&amp;quot;//Item[@type='Activity']&amp;quot;);
  for (int i = 0; i &amp;lt; activeActivities.getItemCount(); i++) {
    Item activeActivity = activeActivities.getItemByIndex(i);
    string activeActivityName = activeActivity.getProperty(&amp;quot;name&amp;quot;, &amp;quot;&amp;quot;);
  }
}&lt;/pre&gt;
&lt;/blockquote&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get WF State programmatically</title><link>https://www.aras.com/community/thread/1130?ContentTypeID=1</link><pubDate>Mon, 18 Dec 2017 05:07:42 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:4fa51aaa-5ff9-43f5-8daa-848dd8d708c0</guid><dc:creator>Former Member</dc:creator><description>Thanks Zahar,

It seems but I can not get the name of that state.

See Image &lt;a href="https://imgur.com/a/nPbNX" target="_blank" rel="noopener"&gt;https://imgur.com/a/nPbNX&lt;/a&gt;

In this case I want to get the &amp;quot;technical review&amp;quot; when if the workflow reach this state.

If I go from Workflow --&amp;gt; Workflow process--&amp;gt; Workflow activity --&amp;gt; Activity I can see the texts

but in the Workflow process I am not sure how can I set the filter to get back the only active process or activity.

Am I missing something here?

&amp;nbsp;

Kind Regards

Mahmoud&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get WF State programmatically</title><link>https://www.aras.com/community/thread/1113?ContentTypeID=1</link><pubDate>Thu, 14 Dec 2017 04:57:59 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:d50e6fe0-640d-47d2-80c4-1f5d948d774c</guid><dc:creator>Zahar Chernov</dc:creator><description>replace {itemID} with the id of your Item

Item wfObj = this.getInnovator().newItem(&amp;quot;Workflow&amp;quot;, &amp;quot;get&amp;quot;);
wfObj.setAttribute(&amp;quot;select&amp;quot;, &amp;quot;keyed_name, source_type(name, keyed_name), source_id,related_id(*)&amp;quot;);
wfObj.setProperty(&amp;quot;source_id&amp;quot;, {itemID});
wfObj = wfObj.apply();

Item wfpObj = (!wfObj .isError()) ? wfObj .getRelatedItem() : null;

&amp;nbsp;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>