Requested Item state

Satish57
Tera Contributor

Hello Folks,

How can I get the requested Item state for the email notification, so that if the state is closed complete, I can print the closed by. If the state is closed skipped/closed Incomplete. I can print the reason.

(var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.request_item)) {

if (ritm.state == 3) {
var Summary = gs.getMessage('Summary details');
var ClosedBy = gs.getMessage('Closed by: {0}', '${closed_by}');
template.print('<p><font size="4" <strong>' + 'Request Approved' + '</strong></font></p>');
template.print('<p><font size="4" color="#808080" face="helvetica"><strong>' + Summary + '</strong></font></p>');
template.print('<p><font size="3" color="#808080" face="helvetica">' + ClosedBy + '</font></p>');

}

if (ritm.state == 4 || 7) {
{
var Summary1 = gs.getMessage('Summary details');
var ClosedBy1 = gs.getMessage('Closed by: {0}', '${closed_by}');

template.print('<p><font size="4" color="#808080" face="helvetica"><strong>' + 'Request Canceled' + '</strong></font></p>');
template.print('<p><font size="4" color="#808080" face="helvetica"><strong>' + Summary1 + '</strong></font></p>');
template.print('<p><font size="3" color="#808080" face="helvetica">' + ClosedBy1 + '</font></p>');
}

} else {
return;
}
}
})(current, template, email, email_action, event);

 

Thanks

1 ACCEPTED SOLUTION

If you have created the notification also on ritm table you can directy get it using

current.state

No need to glide the table

Please mark answer correct/helpful based on impact

View solution in original post

4 REPLIES 4

Saurav11
Kilo Patron
Kilo Patron

Hello

Replace if (ritm.get(current.request_item)) with

if (ritm.get(current))

And

Replace if (ritm.state == 4 || 7) {

with if (ritm.state == 4 || ritm.state==7) {

Please mark answer correct/helpful based on impact

Thanks for the reply Saurav,

I'm not actually get the state value into the if condition, so the conditions doesn't work at all.

If you have created the notification also on ritm table you can directy get it using

current.state

No need to glide the table

Please mark answer correct/helpful based on impact

Thanks Saurav! That actually worked