Aras Developer
Troubleshooting

Fixing Email Notification Issues in Aras Innovator Field Events

Hieu Chu
#email#notifications#AML#Aras Innovator#troubleshooting
Aras Innovator Email Notification Workflow

Send Email to Task Assignee via Field Event in Aras Innovator

Problem Statement

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:

  1. The method isn’t properly linked to the event
  2. There are excessive server calls slowing execution
  3. The email logic contains errors

Root Cause Analysis

The primary issues causing email notification failures are:

  • Incorrect event binding
  • Inefficient server calls in the AML code
  • Missing validation steps before sending emails

Solution Implementation

Optimized Email Notification Code

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;

Implementation Steps

  1. Verify Event Binding:

    • Confirm the method is properly attached to the onChange event of the target field
    • Check server event permissions
  2. Optimize Server Calls:

    • Minimize unnecessary item fetches
    • Use selective property retrieval (setAttribute("select", "..."))
  3. Add Validation:

    • Check for actual value changes before processing
    • Verify recipient existence before sending
  4. Template Management:

    • Store email templates as separate items
    • Use template IDs for easy maintenance

Best Practices

  • Always validate field changes before processing notifications
  • Implement error handling for failed email deliveries
  • Consider adding user confirmation prompts for important notifications
  • Test with various email clients to ensure HTML formatting compatibility

Conclusion

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.