Forum Discussion

lpignedoli's avatar
lpignedoli
Ideator I
7 years ago
Solved

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.getInnovato...
  • Gopikrishnan's avatar
    7 years ago

    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