How to Show catalog item variables on email notifications

Chaitanya Redd1
Tera Guru

Hello Team,

I need help how to show variables which added on catalog form through email notification. As shown below all that variables has to show on email notification. I have tried by creating Script Include.

find_real_file.png

Thanks,

JRY

1 ACCEPTED SOLUTION

Hi,

I have updated code as below and it worked for me

can you update these 2 lines

var value = current.variables.software_selection.toString(); // give proper variable name here

var parser = JSON.parse(value);

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Regards
Ankur

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

View solution in original post

19 REPLIES 19

Hi Mark,

I have tried what Ankur Asked me to do which he shared script. You can find all the images of the script and variables.

 

Thanks,

JRY

Swapnil Soni1
Giga Guru

Hi,

Please try this

current.sysapproval.ref_sc_req_item.variables.<variable_name>

By using "ref_sc_req_item", you are typecasting sysapproval reference which is of type task. Using this syntax you can get not just the variables, but any other fields that are specific to the record that is type casted.

 

Mark correct or helpful if this helps.

Thanks

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

the variable looks to be multi row variable set; you can use email script in the notification as below

MRVS holds JSON value. You need to parse the JSON value

Email Script:

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

          // Add your code here

var value = current.variables.<software_selection>; // give proper variable name here

var parser = JSON.parse(JSON.stringify(value));

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

template.print('Software name is: ' + parser[i].software); // give proper variable name here

template.print('Option is: ' + parser[i].add_remove); // give proper variable name here

}

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

Calling mail script in notification:

${mail_script:show_variables}

find_real_file.png

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Regards
Ankur

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

Hi Ankur,

I have tried your script in Email Script it's not showing Software Selection values on email notification

 

Thanks,

JRY

Hi,

the above notification is on sc_req_item table?

if yes then this should work

Regards
Ankur

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