Context from method to called email

I've got an email that I'm calling from a "post" method on the Part lifecycle, but the default context that's passed to that email message isn't the Part, it instead seems to be the alphabetically first Identity in my database?

Why is this happening, and is it possible to (and how can I) pass the Part as the context item to the email, so I can use xpath variables for that part in the email?

Alternatively, if there's a good way to just find the part that's being promoted via the email message query, that's fine too. That's the goal, however I need to get there.

Here's the method that's running, for what it's worth:

Innovator inn = this.getInnovator();

if (this.getProperty("classification", "") == "Hull Assembly")
{
Item checkIsRoot = this.newItem("Part BOM","get");
checkIsRoot.setAttribute("select","id");
checkIsRoot.setAttribute("maxRecords","1");
checkIsRoot.setProperty("related_id",this.getID());
checkIsRoot = checkIsRoot.apply();
if(checkIsRoot.isError())
{
//First grab an identity to send the mail to.
Item iden = inn.getItemById("Identity", "097FB092EBDE42EB9E5A274ABC0059DA");
//Next, grab the email we want
Item myResult = inn.applyAML("<AML>"+
"<Item type='Email Message' action='get'>"+
"<name>BOM_Release</name>"+
"</Item></AML>");
Item myEmail = myResult.getItemByIndex(0);
iden.email(myEmail, iden);
}
}

return this;

  • I'm still open to other fixes to the above, but I ended up changing the email code (inside the if(checkIsRoot) above) to generate the email directly from the method instead of relying on a pre-defined email notification, and that has worked fine so far, allowing me to get the Part context:

    Item iden = inn.getItemById("Identity", "097FB092EBDE42EB9E5A274ABC0059DA");
    Item fromUser = inn.getItemById("User", "4B70708CE5B7410A9734505699CBFBAB");
    string subject = "Part Promotion Notification";
    string body = "<body><p>Hull BOM ${Item/item_number} has been released as Rev ${Item/major_rev}.</p>" +
    "<p><a href=\"">localhost/.../ follow this link to view Part ${item_number}</a></p>" +
    "</body>";

    Item email_msg = this.newItem("EMail Message");
    email_msg.setProperty("subject", subject);
    email_msg.setProperty("body_html", body);
    email_msg.setPropertyItem("from_user", fromUser);
    if (this.email(email_msg, iden) == false)
    {
    return inn.newError("something went wrong");
    }

  • In this event listener they will be creating the business process. For creating the businessprocess, they will be calling businessProcessService.createProcess(String code, String businessProcessDefinitionName). In this method the code is the unique id for the business process getting created, the businessProcessDefinitionName is the business process's name which got registered in businessprocessRegistry through spring.xml.

    Omegle app