A common issue in Aras Innovator implementations is when email notifications fail to trigger after a field change event (e.g., onChange). This typically occurs when:
The primary issues causing email notification failures are:
Here’s the improved AML code for sending assignment notifications:
Innovator inn = this.getInnovator();
string emailBody = "";
// Get current assignee value
string currentAssignee = this.getProperty("dlv_assignedto", "");
// Fetch updated item data
Item updatedItem = inn.newItem(this.getType(), "get");
updatedItem.setAttribute("select", "dlv_assignedto,item_number");
updatedItem.setID(this.getID());
updatedItem = updatedItem.apply();
string newAssignee = updatedItem.getProperty("dlv_assignedto", "");
// Skip if assignee hasn't changed
if(currentAssignee == newAssignee)
{
return this;
}
// Generate ticket URL
string ticketNumber = updatedItem.getProperty("item_number", "");
string itemType = "DLV_ActionReq";
string baseUrl = CCO.Request.Url.ToString().Substring(0, CCO.Request.Url.ToString().IndexOf("/Server/"));
string ticketLink = string.Format(@"<html><p><a href=\"{2}/Default.aspx?StartItem={0}:{1}\">Click here to open the ticket</a></p></html>",
itemType, ticketNumber, baseUrl);
// Load email template
Item emailTemplate = inn.newItem("Email Message", "get");
emailTemplate.setID("35DF32E58F02491B99B0450DA70AF85E"); // Template ID
emailTemplate = emailTemplate.apply();
// Configure email content
emailTemplate.setProperty("subject",
string.Format("Action Request {0} has been assigned to you", ticketNumber));
emailBody = string.Format(@"<html><B>The following Action Request {0} has been assigned to you. <br>{1} <br>Best regards,<br>Engineering Team</B></html>",
ticketNumber, ticketLink);
emailTemplate.setProperty("body_html", emailBody);
// Send to new assignee
if (!string.IsNullOrEmpty(newAssignee))
{
Item user = inn.newItem("User", "get");
user.setAttribute("select", "id");
Item alias = inn.newItem("Alias", "get");
alias.setAttribute("select", "related_id");
Item identity = inn.newItem("Identity", "get");
alias.setPropertyItem("related_id", identity);
user.addRelationship(alias);
user.setID(newAssignee);
user = user.apply();
if (!user.isError())
{
alias = user.getRelationships("Alias");
Item recipientIdentity = alias.getItemByIndex(0).getRelatedItem();
if(recipientIdentity.getItemCount() == 1)
{
this.email(emailTemplate, recipientIdentity);
}
}
}
return this;
Verify Event Binding:
onChange event of the target fieldOptimize Server Calls:
setAttribute("select", "..."))Add Validation:
Template Management:
Properly configured email notifications significantly improve workflow efficiency in Aras Innovator. By following these steps and using the optimized code, you can ensure reliable delivery of assignment notifications while maintaining system performance. For complex scenarios, consider implementing queue-based email processing to handle high volumes efficiently.