- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2020 11:40 AM
Hello,
I was wondering if I can add more detail to approval requests for specific items. For example, we have workflows for many different catalog items and one is for a new device. I was wondering if it is possible to add the catalog variables in a requested item to the approval request so when the email is sent to the approver they can see the variables. I imagine I will need to create new approval requests for each item I want to show variables.
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2020 07:44 AM
Make sure you are adding the mail script to the correct email template. Review the verbiage of the email template and make sure it matches the Approval Email you are receiving to ensure you are adding the mail script to the correct email template.
See if this helps...this is our approval_request_summary mail script that works for us. It's built so that if a requested item field is empty, don't include it in the Approval request..so we didn't have a bunch of blank fields on the Approval..only include relevant data basically:
template.print("<b>Summary of Requested Item:</b> <br />");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sysapproval);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.cat_item.getDisplayValue() + "<br />");
template.print("Short Description: " + gr.short_description.getDisplayValue() + "<br />");
template.print("<b> Options:</b><br />");
var varown = new GlideRecord('sc_item_option_mtom');
varown.addQuery("request_item", current.sysapproval);
varown.orderBy("sc_item_option.order");
varown.query();
while (varown.next()){
var visible = varown.sc_item_option.item_option_new.visible_summary;
var question = GlideappAbstractChoiceListQuestion.getQuestion(varown.sc_item_option.item_option_new);
question.setValue(varown.sc_item_option.value);
if (JSUtil.notNil(question.getLabel()) && JSUtil.notNil(question.getDisplayValue()) && question.getDisplayValue() != 'false' && question.getDisplayValue() != "-- None --" && visible == true){
template.space(4);
template.print(' ' + question.getLabel() + " = " + question.getDisplayValue() + "<br />");
}
}
}
and below is how it is added to our Approval notification (this is just a few lines from the notification):
<div>You have been identified as an Approver for the below item. Please approve or reject by clicking one of the links below and sending the resulting email.</div>
<div>
<div><hr /></div>
</div>
<div>${mail_script:approval_request_summary}</div>
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2020 11:48 AM
You can create an email script that pull fields from the RITM and include that mail script in the email template on the Approval Request notification like this:
<div>${mail_script:approval_request_summary}</div>
Since the mail script will be querying the RITM to get the variables, you can use the same approval request for all items. It will just query the variables and add them to the Approval Request.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2020 06:31 AM
Do you know what that mail script should look like? Sorry, I am newer to scripting.
There is a requested item summary with options email script that I tried inserting in the template used within the approval request notification but it doesn't generate anything. This is what it contains..
template.print("Summary of Requested items:<br />");
var item = new GlideRecord("sc_req_item");
item.addQuery("request", current.sysapproval);
item.query();
while(item.next()) {
template.print(item.number + ": " + item.quantity + " X " + item.cat_item.getDisplayValue() + " at " + item.cat_item.price.getDisplayValue() + " each <br />");
template.print(" Options:<br />");
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++) {
if(vs.get(i).getLabel() != '') {
template.space(4);
template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "<br />");
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2020 07:44 AM
Make sure you are adding the mail script to the correct email template. Review the verbiage of the email template and make sure it matches the Approval Email you are receiving to ensure you are adding the mail script to the correct email template.
See if this helps...this is our approval_request_summary mail script that works for us. It's built so that if a requested item field is empty, don't include it in the Approval request..so we didn't have a bunch of blank fields on the Approval..only include relevant data basically:
template.print("<b>Summary of Requested Item:</b> <br />");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sysapproval);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.cat_item.getDisplayValue() + "<br />");
template.print("Short Description: " + gr.short_description.getDisplayValue() + "<br />");
template.print("<b> Options:</b><br />");
var varown = new GlideRecord('sc_item_option_mtom');
varown.addQuery("request_item", current.sysapproval);
varown.orderBy("sc_item_option.order");
varown.query();
while (varown.next()){
var visible = varown.sc_item_option.item_option_new.visible_summary;
var question = GlideappAbstractChoiceListQuestion.getQuestion(varown.sc_item_option.item_option_new);
question.setValue(varown.sc_item_option.value);
if (JSUtil.notNil(question.getLabel()) && JSUtil.notNil(question.getDisplayValue()) && question.getDisplayValue() != 'false' && question.getDisplayValue() != "-- None --" && visible == true){
template.space(4);
template.print(' ' + question.getLabel() + " = " + question.getDisplayValue() + "<br />");
}
}
}
and below is how it is added to our Approval notification (this is just a few lines from the notification):
<div>You have been identified as an Approver for the below item. Please approve or reject by clicking one of the links below and sending the resulting email.</div>
<div>
<div><hr /></div>
</div>
<div>${mail_script:approval_request_summary}</div>
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 09:15 AM - edited 02-24-2023 09:15 AM
Great post on this, much appreciated. How would you change the script, assuming you have an attachment variable type, to include the attachment name with a link, or even attach it to the approval email alltogether?