How to get requested item number & cat_item in notification (notification is on Request table)

Chadaram Lokesh
Tera Contributor

Need to get the requested item & catalog item name in notification body & subject. This notification is taken on request table. 

find_real_file.png

help me the way to fulfill this.

Thank you.

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi,

Since notification is on request table you need a mail script. Try something as below.

System Notification >> Email >> Notification Mail script.

Create New: getritmdetails

with script as below

(function runMailScript(current, template, email, email_action, event) {

    var getritm = new GlideRecord('sc_req_item');
    getritm.addQuery('request', current.sys_id);
    getritm.query();
    if (getritm.next()) {
        template.print('Requested Item: ' + getritm.number);
        template.print('Catalog Item: ' + getritm.cat_item.getDisplayValue());
    }

})(current, template, email, email_action, event);

 

Call mail script in notification body field as below

${mail_script:getritmdetails}

View solution in original post

6 REPLIES 6

Jaspal Singh
Mega Patron
Mega Patron

Hi,

Since notification is on request table you need a mail script. Try something as below.

System Notification >> Email >> Notification Mail script.

Create New: getritmdetails

with script as below

(function runMailScript(current, template, email, email_action, event) {

    var getritm = new GlideRecord('sc_req_item');
    getritm.addQuery('request', current.sys_id);
    getritm.query();
    if (getritm.next()) {
        template.print('Requested Item: ' + getritm.number);
        template.print('Catalog Item: ' + getritm.cat_item.getDisplayValue());
    }

})(current, template, email, email_action, event);

 

Call mail script in notification body field as below

${mail_script:getritmdetails}

For subject add

email.setSubject('RITM is '+getritm.number +' Catalog item '+getritm.cat_item.getDisplayValue());

just before 

}

& after template.print ....

from earlier comments.

Hi jaspal,

In email script, have to mention this. when i take this in subject it showing only the catalog item.

I need to show the subject as "Request ${number} for (here catalog item come) has been opened on your behalf".

Hi @Chadaram Lokesh 

I believe Jaspal provided the solution, but if you want to set the subject as you expected.

Just update the line like below but mark the Jaspal solution as correct:

email.setSubject('Request is '+getritm.request+' for '+getritm.cat_item.getDisplayValue() +'  has been opened on your behalf');

 

Thanks

Murthy

Thanks,
Murthy