Forum Discussion
Sudarshan_Srinath1
7 years agoIdeator II
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("major_rev");
// Get the latest generation
Item newVer = this.newItem(this.getType(), "get");
newVer.setProperty("config_id", this.getProperty("config_id"));
newVer.setProperty("is_current", "1");
newVer = newVer.apply();
string new_rev = newVer.getProperty("major_rev","");
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("remove_Prop", "1");
RequestState.Add("newRevision", new_rev);
RequestState.Add("newRevisionID", 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