Catalog Item Owner on Request notification

Russell Abbott
Kilo Sage

I have a requirement to include in the email notification for a Request closure, the Catalog Item Owner for the associate RITM.

In the email notification i tried the following

"If you feel that your Request was closed improperly, you can escalate to ${variables.cat_item.owner.name} at ${variables.cat_item.owner.phone}" but these values do not seem to bring anything over, blank.

Does anyone have any insight here? I'm aware that some Requests may have multiple RITM's, so i don't know how that would be handled. The majority of our Requests have one RITM.

1 ACCEPTED SOLUTION

Rather than trying to access the custom field you created, you can access through the cat_item field. I recreated accessing the name and phone from the user record that is on the Catalog Item record. To reproduce, get the sys_id of a Request record, then run the following:

var reqGr = new GlideRecord('sc_request');
reqGr.get('sys_id_of_request_record'); //place the sys_id of the current request record
var itmGr = new GlideRecord('sc_req_item');
itmGr.addQuery('request', reqGr.sys_id);
itmGr.setLimit(1);
itmGr.query();
if(itmGr.next()) {
    gs.log(itmGr.cat_item.owner.name); //Here is where you get the owner name
    gs.log(itmGr.cat_item.owner.phone); //Here is where you get the owner phone
}

Taking what you indicated there are pieces that are not necessary, so I refactored the mail_script to incorporate the code from above:

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */ event) {

    var itmGr = new GlideRecord('sc_req_item');
    itmGr.addQuery('request', reqGr.sys_id);
    itmGr.query();
    var rowCount = itmGr.getRowCount();
    var ownerName = '';
    var ownerPhone = '';
    var printText = '';
    while (itmGr.next()) {
        ownerName += itmGr.cat_item.owner.name;
        ownerPhone += itmGr.cat_item.owner.phone;
        printText += itmGr.number + ': ' + ownerName + ' at ' + ownerPhone;
    }
    template.print('<span style="font-family: Montserrat;font-size: 12pt;">' + printText +'</span>');
})(current, template, email, email_action, event);

View solution in original post

11 REPLIES 11

Periyasamy P
Tera Guru

As you mentioned it would be good to have notification in RITM table with event trigger. So that, you can trigger these events from request table BR which will be running on closure. 

 

Also, it would be to aggregate notification on owner level instead of sending multiple emails to same user.

ccajohnson
Kilo Sage

If this is on the Request record, your path does not make sense. Since variables are on the Requested Item and not the Catalog Request record.

Something you could do is to leverage notification scripting that will do the appropriate searching for the catalog item owner name and phone. Let me know if you have any questions on how to do this and we can assist.

Our current notifications are based on the Request record so that is where the ask has come from. With those notifications already in place and common among our end users, we would be looking to stick with those if possible.

I figured email scripting would be the only way here.

If you had any suggestions, those would be very much appreciated!

Regards

Russ

What you can do is to find the Requested Item records that relate to the Request. Once you have found a requested item, then you dot-walk to the owner and owner phone of the Catalog Request of that requested item storing each into a variable that you can use in the wording of the email script.

What I would do first is to determine how to get to a related requested item record. Then, I would determine how to get the owner and owner phone. Then, I would take the values of owner name and owner phone and use it in the email script.

If you are familiar with Scripts - Background, you can do your experimenting there so that you do not have to create a request to test.

Let me know if you need further assistance.