How to get values from a event parameters and use them in a notification

matthew_hughes
Kilo Sage

I'm trying to setup a notification for when a certain catalogue item is completed. The catalogue item contains a list of business application that a user chooses to update. I've created a business rule that triggers the event:

matthew_hughes_0-1736519664875.png

 

I'm trying to use the following code to find any business applications that had been updated at the same time:

matthew_hughes_1-1736519764045.png

However, what I find is that nothing is being returned in the logs even though a business application has been updated through the catalogue item.

 

My email notification is using the Business Application table:

matthew_hughes_2-1736519970202.png

 

What I'm finding is that the ${u_business_owner} and ${department} fields are not getting updated:

matthew_hughes_3-1736520046347.png

If somebody can advise what I need to do to retrieve the values, that would be great.

 

 

 

16 REPLIES 16

Thanks @Ankur Bawiskar 

 

For one of my variables, it's a list of collector. This contains a list of selected Business Applications. There are two things that I'm wanting to extract:

1. The business owner of each business application

2. How do I extract the list of each business application assigned to the Business Owner?

@matthew_hughes 

then query that table which is being referred by that list collector

iterate and print the owner

something like this, please enhance

var val = current.variables.listCollectorVariableName;

var gr = new GlideRecord("cmdb_ci_business_app");
gr.addQuery("sys_id", "IN", val.toString());
gr.query();
while (gr.next()) {
    template.print('Owner ' + gr.owner.getDisplayValue());

    // then query again with same table with this owner and print the Business app name

    var gr1 = new GlideRecord("cmdb_ci_business_app");
    gr1.addQuery("owner", "IN", gr.owner);
    gr1.query();
    while (gr1.next()) {
        template.print('Business app  ' + gr.getDisplayValue());
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar I've got the business applications to display in list view by using the following:

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    var val = current.variables.business_applications_to_update;

    var gr = new GlideRecord("cmdb_ci_business_app");
    gr.addQuery("sys_id", "IN", val.toString());
    gr.query();
    while (gr.next()) {
        template.print("<ul>");
        template.print("<li>" + gr.number + " - " + gr.getDisplayValue() + "</li>");
        template.print("</ul>");
        //template.print('Owner ' + gr.u_business_owner.getDisplayValue());

        // then query again with same table with this owner and print the Business app name
        //template.print('Business app  ' + gr.getDisplayValue());
        }
   
})(current, template, email, email_action, event);
 
matthew_hughes_0-1736778630985.png

 

However, from the list of business applications, each one will have a different business owner. So I'm wanting an email to be generated to each business owner and show only the selected Business Applications that they are the owner of. Do you know what I need to do to achieve that?

@matthew_hughes 

I believe I have provided answer to your original question.

If my response helped please mark it correct as well so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@matthew_hughes 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader