How to send the notification with all the populated data in the requested item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 07:08 AM
Hello Everyone,
I have a requirement where I need to send the notification via mail script with all the data in the requested item. Can anyone help me in achieving this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 07:49 AM
Hi,
you can use this script and print all variables
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('Variable Summary: <br/>');
var variables = curent.variables.getElements();
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if(label != ''){
template.space(4);
template.print(' ' + label + " = " + value + "<br/>");
}
}
})(current, template, email, email_action, event);
regards
Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2022 08:53 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
Regards
Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 07:31 AM
Hello Poorna,
I would request you to please try below script in email notification scripts to fetch al variable of catalog item:
template.print("<font style='font-size: 10pt; font-family: arial;'>");
template.print("Summary of options:<br />");
var item = new GlideRecord("sc_req_item");
item.addQuery("sys_id", current.sys_id);
item.query();
if(item.next())
{
template.print("<p style='font-size: 10pt; font-family: arial;'>");
//template.print(item.number + " : " + item.cat_item.getDisplayValue() + "<br />");
template.print("<p style='font-size: 10pt; font-family: arial;'>Options:<br />");
template.print("<br /></p>");
var keys = [];
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(item.sys_id);
set.load();
var vs = set.getFlatQuestions();
for (var i=0; i < vs.size(); i++) {
template.space(2);
template.print("<font style='font-size: 10pt; font-family: arial;'>");
template.print(vs.get(i).getLabel() + ' ' + '=' + ' ' + vs.get(i).getDisplayValue() );
template.print("</font><br/>");
}
}
Please mark it as right if it helps you.
BR,
Nayan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 07:46 AM
hello
try this script in email script it worked for me
var variableList = current.variables.getElements();
for(var i=0; i<variableList.length; ++i)
{
var variable = variableList[i];
if(variable.getLabel()!='')
{
template.print('<strong>'+variable.getLabel()+ ': </strong>'+variable.getDisplayValue()+'<br>');
}
}
PLEASE MARK MY ANSWER CORRECT IT IT HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 09:04 AM
Hi Poorna,
After defining your email script, call it in your Email Notification > 'What it will contain' section using
${mail_script:email_script_name}
Mark this as Correct/Helpful if it helps.
Regards,
Shubham