<?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>How to call method when new revision of Item is created</title><link>https://www.aras.com/community/f/getting-started/3427/how-to-call-method-when-new-revision-of-item-is-created</link><description>Hi experts,

 

I want to call a method, when new revision of an item is created, in that method I start the workflow for new revision of an Item.

so on which server event should I call &amp;quot;startWF&amp;quot; method?

Thanks,

Maddy.</description><dc:language>ja-JP</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to call method when new revision of Item is created</title><link>https://www.aras.com/community/thread/911?ContentTypeID=1</link><pubDate>Thu, 12 Oct 2017 08:14:48 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:f870e4b6-50e5-4752-be3d-e7b4d2a57f16</guid><dc:creator>Maddy</dc:creator><description>Hi Chris,
I add logic of promote Item, which helps me to promote Item from one state to other when I complete a task, but one problem still persist that Worked Item in My InBasket still showing as &amp;quot;&lt;strong&gt;Restricted&lt;/strong&gt;&amp;quot;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call method when new revision of Item is created</title><link>https://www.aras.com/community/thread/909?ContentTypeID=1</link><pubDate>Thu, 12 Oct 2017 01:46:44 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:35730be9-f96c-4316-bfd8-99c6faed58a1</guid><dc:creator>Maddy</dc:creator><description>Thank you so much for you reply.

I add my logic of start workflow in that if condition it works fine, but the life cycle state of the item will not promoted when I complete my task.

It should get change from In work to review, so for that we have to promote life cycle through coding?

and  one more question after workflow gets start from coding, when task is created in My Inbasket, the &lt;strong&gt;Worked Item&lt;/strong&gt; is showing Restricted.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call method when new revision of Item is created</title><link>https://www.aras.com/community/thread/907?ContentTypeID=1</link><pubDate>Wed, 11 Oct 2017 13:57:27 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:f1aa8de6-7bd8-4928-ad2e-bf9d90e803a5</guid><dc:creator>Christopher Gillis</dc:creator><description>Hi Maddy,

If you want to call this Method whenever the generation of an Item is increased, you can call it from an onAfterVersion server event on the ItemType.

If you want to call this Method for every increment of the &amp;quot;major_rev&amp;quot; property, there is no built in event to handle this. However, you can call the following Methods from an onBeforeVersion/onAfterVersion server event to check if the major_rev has been increased between them.

onBeforeVersion:

&lt;pre&gt;&lt;code&gt;

Innovator inn = this.getInnovator();

// Get the major_rev before the version
Item myPart = inn.newItem(&amp;quot;Part&amp;quot;, &amp;quot;get&amp;quot;);
myPart.setID(this.getID());
myPart.setAttribute(&amp;quot;select&amp;quot;, &amp;quot;major_rev&amp;quot;);
myPart = myPart.apply();
string prevRev = myPart.getProperty(&amp;quot;major_rev&amp;quot;);

RequestState.Add(&amp;quot;prevRev&amp;quot;, prevRev); // Add value to SessionState
return this;&lt;/code&gt;&lt;/pre&gt;


onAfterVersion:

&lt;pre&gt;&lt;code&gt;

Innovator inn = this.getInnovator();

string prevRev = (string)RequestState[&amp;quot;prevRev&amp;quot;];

// Get the most recent version of this item
Item newItem = inn.newItem(&amp;quot;Part&amp;quot;, &amp;quot;get&amp;quot;);
newItem.setProperty(&amp;quot;config_id&amp;quot;, this.getProperty(&amp;quot;config_id&amp;quot;));
newItem.setProperty(&amp;quot;is_current&amp;quot;, &amp;quot;1&amp;quot;);
newItem.setAttribute(&amp;quot;select&amp;quot;, &amp;quot;major_rev&amp;quot;);
newItem = newItem.apply();
string currRev = newItem.getProperty(&amp;quot;major_rev&amp;quot;);

// If the major_rev&amp;#039;s are not equal, the item has been versioned
if (prevRev != currRev)
{
// Put logic here
}

return this;&lt;/code&gt;&lt;/pre&gt;


Any logic you want to run when an item is versioned can be placed in the if statement in the onAfterVersion event.

Chris

_______________________

Christopher Gillis

Aras Labs Software Engineer&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>