CA Application Lifecycle Conductor

Expand all | Collapse all

How to trigger an email notification based on item attribute values

Jump to Best Answer
  • 1.  How to trigger an email notification based on item attribute values

    Posted 03-22-2018 01:38 PM

    On CA ALC we have a "Notification" rule type and we need to know how to trigger this rule based con an attribute value in order to accomplish some requirements, ex: Notify an Item Assignee, notify testers when item is at some Status, etc...

     

    Someone knows how to do this

     

    Thanks for your help.

    Regards,

    JOHN



  • 2.  Re: How to trigger an email notification based on item attribute values
    Best Answer

    Posted 03-23-2018 01:43 PM

    To configure ALC to send an email message if the status of your item changes, we will create a “Field Change Tracker” rule and specify the field(s) you want to watch for a change in the “Fields” list – in this example I am adding my new Field Change Tracker rule to the "After Save Item" event of the "Project" item type and I have configured it to watch for any change to the “Status” field:

    If you only want the message to be sent if a certain specific status is set, you would add a condition, something like this

    :

    Under the Field Change Trigger rule we will insert a Notification rule. 

    Be sure to specify the user or group who will receive the message in the Recipients list:

    Then edit the script to provide overrides for subject and body:

    This will allow us to customize the message based on the status.

     

    Let me know if this is what you needed.



  • 3.  Re: How to trigger an email notification based on item attribute values

    Posted 03-27-2018 11:20 AM

    Great resource! Thanks a lot for this tip.

    Best Regards,

    JOHN



  • 4.  Re: How to trigger an email notification based on item attribute values

    Posted 04-04-2018 10:02 AM

    Melinda, about Recipients... could we define a variable (ex: item assignee or any other contact related field).

    Thanks,

    JOHN



  • 5.  Re: How to trigger an email notification based on item attribute values

    Posted 04-05-2018 10:50 AM

    I mean, someway to override the recipients list based con contact from item detail like 'assignee', 'Project Manager', 'Created by', or any custom field based on Contacts.

     

    Thanks for your comments.

    Best Regards,

    JOHN



  • 6.  Re: How to trigger an email notification based on item attribute values

    Posted 04-12-2018 09:46 PM

    Question is:

    How can I configure a notification rule so that the recipient is a person associated with the item – for example a Project Manager for the Project item type, or Requestor for the Requirement item type?  A special rule type exists for sending a notification email to the person assigned to an item, but what about other types of persons?

     

    Answer:

    The way to do this is to add functionality to the Notification Rule Type so that the notification email recipient can be overridden in the same way that the message body and subject can.  To accomplish this, edit the script for the Notification Rule Type as follows:

     

    Locate the following code segment:

     

    // Set up recipients as list

    var orgEntries = new java.util.ArrayList();

    for (var i = 0; i < recipients.length; i++)

        orgEntries.add(recipients[i]);

     

    And replace it with this:

     

    // Set up recipients as list

    var orgEntries = new java.util.ArrayList();

    //*** Original code segment ************************************

    // for (var i = 0; i < recipients.length; i++)

    //     orgEntries.add(recipients[i]);

    //*** Replacement code segment *********************************

    if (typeof recipOverride != "undefined") {

        orgEntries.add(recipOverride);

    } else {

        for (var i = 0; i < recipients.length; i++)

            orgEntries.add(recipients[i]);

    }

    //*** End of code change **************************************

     

    Now that you have a way to override the recipient list for the notification email, you can make use of it when this is needed, but use the standard recipient list when that will work better.

     

    Here is an example of a notification rule script for the Project item type that overrides the subject of the message, the body, and the recipient:

     

    //*** Begin script ********************************************

    var itemName = item.getName();

    var status = item.getAttributes().getItemByAttributeTypeName("Status").getText();

    var prjmgr = item.getAttributes().getItemByAttributeTypeName("Project Manager").getValue();

    var prjmgrName = prjmgr.getName();

     

    subjectOverride = "The item name is " + itemName;

    bodyOverride = "The status is " + status + " and the project manager is " + prjmgrName;

    recipOverride = prjmgr;

     

    #EXECUTE_DEFAULT_SCRIPT#

    //*** End script ********************************************



  • 7.  Re: How to trigger an email notification based on item attribute values

    Posted 04-16-2018 12:25 PM

    Thanks for your help Melinda. It works like a charm! Great resource.

     

    Best Regards,

    JOHN