<?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>Remove certain property values onAfterVersion an Item</title><link>https://www.aras.com/community/f/development/3997/remove-certain-property-values-onafterversion-an-item</link><description>Hi,

this one sounds like an easy to do task, but it&amp;#180;s somehow not. I want to reset certain ERP related properties after creating a new generation of a Part.

My idea was to use a simple onAfterVersion Method for this task:
 innnovator inn=this.getInnovator</description><dc:language>ja-JP</dc:language><generator>Telligent Community 12</generator><item><title>RE: Remove certain property values onAfterVersion an Item</title><link>https://www.aras.com/community/thread/2218?ContentTypeID=1</link><pubDate>Tue, 06 Nov 2018 03:26:11 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:a7f09cda-3138-458f-b641-272155a30940</guid><dc:creator>Sudarshan_Srinath</dc:creator><description>Im glad that this approach worked for you. Do revert if you have any other issues that i can help you with
/Sudarshan&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove certain property values onAfterVersion an Item</title><link>https://www.aras.com/community/thread/2217?ContentTypeID=1</link><pubDate>Mon, 05 Nov 2018 10:23:28 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:0a2a52ed-6ffc-4f90-bb37-ac9cb7cc54bb</guid><dc:creator>jtensmeyer</dc:creator><description>Sudarshan,

You were correct.  Thanks for pointing that out.  I had tried that approach before when I was just using the OnAfterVersion approach but did not try it after splitting it into the OnBeforeUpdate.

Thank you for helping me sleep better.  That problem was driving me crazy.

John&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove certain property values onAfterVersion an Item</title><link>https://www.aras.com/community/thread/2216?ContentTypeID=1</link><pubDate>Mon, 05 Nov 2018 09:55:48 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:29823509-8565-48e2-88a4-744a825fd8d0</guid><dc:creator>Sudarshan_Srinath</dc:creator><description>&lt;code&gt;this.setProperty(&amp;quot;desired_property&amp;quot;,&amp;quot;desired_value&amp;quot;)&lt;/code&gt;

I will not set double update on the same item with an extra item action
since you are in the very context that item this.setProperty(&amp;quot;&amp;quot;,&amp;quot;&amp;quot;) should work&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove certain property values onAfterVersion an Item</title><link>https://www.aras.com/community/thread/2215?ContentTypeID=1</link><pubDate>Fri, 02 Nov 2018 16:36:45 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:3a7f013f-cfb8-4c1f-9eda-ed65d753fbe8</guid><dc:creator>jtensmeyer</dc:creator><description>Hello Sudarshan and Angela,

Thank you for this discussion.  I have been trying to do something very similar.  I implemented the state variable method in the OnBeforeUpdate event as you described but I am still not seeing the changes on the newly created generation of the part.  I have verified in the debugger that it does go through the logic of finding the set state variable and the variable has the right value in it and that the id of the part is the correct one (the new generation).  However, the property changes do not show up.  If I change the action to &amp;quot;edit&amp;quot; I get an  &amp;quot;ItemIsNotLocked&amp;quot;  exception.   Any idea what I might be doing wrong?

Thanks,

John Tensmeyer

&amp;nbsp;
&lt;blockquote&gt;// Called OnBeforeUpdate for Parts and Documents.

string setRev= (string)RequestState["set_MinRev"];

// this logic will only applied if the variable is available in session state
if (!string.IsNullOrEmpty(setRev))
{
Item myPart = this.newItem(this.getType(), &amp;quot;edit&amp;quot;);
myPart.setProperty(&amp;quot;ws_minor_rev&amp;quot;, setRev);
myPart.setProperty(&amp;quot;name&amp;quot;,&amp;quot;goober&amp;quot;);
string newID = this.getID();
myPart.setID(newID);
myPart.setAttribute(&amp;quot;version&amp;quot;,&amp;quot;0&amp;quot;);
myPart.setAttribute(&amp;quot;serverEvents&amp;quot;,&amp;quot;0&amp;quot;);
myPart = myPart.apply();
if (myPart.isError())
return myPart;
}
return this;&lt;/blockquote&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove certain property values onAfterVersion an Item</title><link>https://www.aras.com/community/thread/2214?ContentTypeID=1</link><pubDate>Tue, 30 Oct 2018 05:12:25 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:2dbb991b-8180-4f2a-b128-b80d63f2b213</guid><dc:creator>AngelaIp</dc:creator><description>Hi Sudarshan,

thanks for the additional idea! I can confirm, that this one is also suitable!

I right identified couple of tasks that I want to trigger after versioning an Item. 
So right now, I cannot tell, which of the two version here fits better to my application, but I can confirm that both of them work!

Best regards!
Angela&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove certain property values onAfterVersion an Item</title><link>https://www.aras.com/community/thread/2213?ContentTypeID=1</link><pubDate>Mon, 29 Oct 2018 09:10:40 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:a54e0984-c249-447f-932f-0b20db9c7a6e</guid><dc:creator>Sudarshan_Srinath</dc:creator><description>This will be executed on afterversion we add 3 session state variables to the method

remove_prop, newRevsion and newRevisionID

these vars will be used in onbeforeupdate method of the same item

remove_prop variable can be used in onbefore update see below in method 2

Method 1 action :-onafterversion

//Collect old rev for comparison
string old_rev = this.getProperty(&amp;quot;major_rev&amp;quot;);
// Get the latest generation
Item newVer = this.newItem(this.getType(), &amp;quot;get&amp;quot;);
newVer.setProperty(&amp;quot;config_id&amp;quot;, this.getProperty(&amp;quot;config_id&amp;quot;));
newVer.setProperty(&amp;quot;is_current&amp;quot;, &amp;quot;1&amp;quot;);
newVer = newVer.apply();
string new_rev = newVer.getProperty(&amp;quot;major_rev&amp;quot;,&amp;quot;&amp;quot;);
string newRevId = newVer.getID();
// If new revision send the remove_Prop flag to be processed in onBeforeupdate()
if (!new_rev.Equals(old_rev))
{
RequestState.Add(&amp;quot;remove_Prop&amp;quot;, &amp;quot;1&amp;quot;);
RequestState.Add(&amp;quot;newRevision&amp;quot;, new_rev);
RequestState.Add(&amp;quot;newRevisionID&amp;quot;, newRevId);


}

Method 2 action: OnBeforeUpdate

string removeProps= (string)RequestState["remove_Prop"];
string newRevision = (string)RequestState["newRevision"];
string newItemID = (string)RequestState["newRevisionID"];

// this will logic will only applied if the variable is availabe in session state
if (!string.IsNullOrEmpty(removeProps))
{

your logic to remove the props here

}

let me know if this helps you&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove certain property values onAfterVersion an Item</title><link>https://www.aras.com/community/thread/2212?ContentTypeID=1</link><pubDate>Mon, 29 Oct 2018 05:40:04 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:760a9aa0-3067-4820-a762-29f4ba79c9ae</guid><dc:creator>AngelaIp</dc:creator><description>Hi Andreas,

interesting solution! I made some tests with onBeforeAdd, but never came to the idea of using onBeforeUpdate.
I can confirm, that your solution works for new item versions created by CM-processes.

We also allow manual revising parts on certain conditions (change of major_rev, minor_rev and generation). The above solution will not work for these ones, but it´s not a big issue to extend Methods like PE_CreateNewRevision. 

Your code helps to avoid additional customizations in the transition handlers. I have customized them so often, I really don´t want to do it again. So your solution is big help!

Thanks and best regards!
Angela&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove certain property values onAfterVersion an Item</title><link>https://www.aras.com/community/thread/2211?ContentTypeID=1</link><pubDate>Fri, 26 Oct 2018 14:38:13 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:384f2a19-a79b-403d-9e06-4485fc70f133</guid><dc:creator>Andreas S.</dc:creator><description>Hi Angela,

I had this issue a few months ago. It seems that after the OnAfterVersion event always a on***update event is fired.
In this case it seems that &lt;code&gt;this&lt;/code&gt; only contains few properties (anyhow: id). 
So maybe the following code snippet called by a onbeforeupdate event may help yo:
&lt;pre&gt;&lt;code&gt;string configId = this.getProperty(&amp;quot;config_id&amp;quot;);
if(String.IsNullOrEmpty(configId))
{
   // We are coming from change management, in case of &amp;#039;normal&amp;#039; update configId isn&amp;#039;t empty
   this.setProperty(&amp;quot;erp_is_matched&amp;quot;,&amp;quot;0&amp;quot;);
} 
&lt;/code&gt;&lt;/pre&gt;

I don&amp;#39;t really understand why - but in my case it works.
I hope this will help you.

Best regards,
Andreas&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>