- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 03:47 AM
[CHALLENGE]
I have a catalog item with a select box containing multiple items to choose from, that has a price variable assigned, and I need to template.print() that price in an email notification or an email notification script.
[QUESTION]
How do I go about doing that? I spend most of a day trying to figure it out (dot walk, current.variables, glide records) but I have not been successful, other then getting the total price of all selected question topics on the catalog item by using ${current.price}.
[VARIABLE SETUP]
I hope someone can help me out 🙂 I am fairly new to javascript and service-now, but have experience in html5, php, sql
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 11:10 PM
Hi,
you will require email script for this
I hope you are aware on how to include email script in email body
Something like this
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var variableValue = current.variables.hvilken_model;
var gr = new GlideRecord("question_choice");
gr.addQuery("value", variableValue);
gr.query();
if (gr.next()) {
template.print("Price " + gr.misc);
}
})(current, template, email, email_action, event);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 11:10 PM
Hi,
you will require email script for this
I hope you are aware on how to include email script in email body
Something like this
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var variableValue = current.variables.hvilken_model;
var gr = new GlideRecord("question_choice");
gr.addQuery("value", variableValue);
gr.query();
if (gr.next()) {
template.print("Price " + gr.misc);
}
})(current, template, email, email_action, event);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 11:33 PM
Hi Ankur,
This works perfect 🙂 thank you.
Can you also show me how to add the Text and Value from the price table to the template.print?
example result could be :
template.print(gr.text + "Price " + gr.misc); //gr.text prints NaN when I try now 😞
that should print :
iPhone 13 (128gb) Price 4.666
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2022 02:54 AM
This solved it 🙂 thanks for the help 🙂
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var variableValue = current.variables.hvilken_model;
var gr = new GlideRecord("question_choice");
gr.addQuery("value", variableValue);
gr.query();
if (gr.next()) {
var pris = gr.misc;
var grquest = gr.value;
template.print("Model " + grquest);
template.print(" Pris " + pris);
}
})(current, template, email, email_action, event);