Method for event OnAfterUnlock
I want to promote an Item state when user unlock it.
I create a simple LifeCycle: "New"-->"Released"
I habe write this method on the server event "OnAfterUnlock":
Innovator inn=this.getInnovator();
string itemnumber = this.getProperty("item_number");
string state=this.getProperty("state","");
if ( state != "Released" ){
CCO.Utilities.WriteDebug("IP_ScadDocsPromote","Item = "+itemnumber +" State = " + state);
this.promote("Released","");
}
return this;
But it doesn't work. The log IP_ScadDocsPromote show me that the variables "itemnumber" and "state" are blank.
Thanks for your help.
Hi
onAfterUnlock action will have info about the ID and Type of the item type. We need to fetch information again to get the item number and state information.
// First Line is a debugger. You can debug server methods. Please have look at https://community.aras.com/b/english/posts/debugging-in-aras-innovator
// if (System.Diagnostics.Debugger.Launch()) System.Diagnostics.Debugger.Break();
var queryItem = this.newItem(this.getType(), "get");
queryItem.setAttribute("select", "item_number,state");
queryItem.setID(this.getID());
queryItem = queryItem.apply();
if (!queryItem.isError())
{
string itemnumber = queryItem.getProperty("item_number");
string state= queryItem.getProperty("state","");
if ( state != "Released" )
{
CCO.Utilities.WriteDebug("IP_ScadDocsPromote","Item = "+itemnumber +" State = " + state);
this.promote("Released","");
}
}
return this;Thank You
GK