onAfterPromote Event

Hi,

I have a requirement to trigger a method on after Promote. How to get the controlled item and its properties on the onAfterPromote event similar to the one using Get Controlled Item in workflow.

  • Hello,

    The context item from an onAfterPromote server event is the controlled item already, so you should be able to access the data using this as in the example below.

    this.getProperty("keyed_name"); // Get the Keyed Name of the controlled item

    Chris

    Christopher GIllis

    Aras Labs Software Engineer

  • Hi christopher

    I was trying to get the state of the item and id using below line but I was not able to get on onAfterPromote Server event

    string itemID = this.getID(); 
    string state = this.getProperty("state");

  • Hello,

    In further testing, it appears that the context item for onBefore/onAfterPromote is formatted differently. It contains a list of ids that you can use to look up the part(s) affected by the promotion similar to the sample below.

    // Get the Part(s) affected by this promotion
    string idlist = this.getAttribute("idlist");
    Item parts = inn.newItem("Part", "get");
    parts.setAttribute("idlist", idlist);
    parts = parts.apply();

    // This only requires a for loop to account for special actions like Mass Promote
    for (int i = 0; i < parts.getItemCount(); i++)
    {
    Item part = parts.getItemByIndex(i);
    string id = part.getID();
    string state = part.getProperty("state", "");
    // Put your business logic below here
    }

    return this; // Return some item to avoid a compilation error

    Please note that this sample was written in 11.0 SP15. If this sample does not work in your environment, please provide which version of Aras Innovator you are using.

    Chris

    Christopher Gillis

    Aras Labs Software Engineer