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.

Parents Reply Children
  • 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