- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 06:51 AM
Is there an easy way to map ALL of the variables from a catalog item to the description field of an Incident? I know I can go in and add current.variable = producer.variable; to the record producer but I'm curious if there is an easy way to add ALL of the variables from the catalog item to the description field of an Incident.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 08:42 AM
I'm using the catalog item/workflow to generate the Incident. I got it to work by just coding it all out in the "Create Task" script field as follows:
task.caller_id = current.variables.requester_name.getDisplayValue();
task.short_description = current.variables.issue_type.getDisplayValue();
var issueType = current.variables.issue_type.getDisplayValue();
if (issueType == 'Outlook Problem') {
task.description = 'Issue Type: ' + issueType + '\nOutlook Problem: ' + current.variables.outlook_problem.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Computer Problem') {
task.description = 'Issue Type: ' + issueType + '\nComputer Problem: ' + current.variables.computer_problem.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Unable To Scan Docs') {
task.description = 'Issue Type: ' + issueType + '\nUnable to Scan Docs: ' + current.variables.unable_to_scan.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Internet Browser Problem') {
task.description = 'Issue Type: ' + issueType + '\nBrowser Problem: ' + current.variables.browser_problem.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Unable to Login to access.fnf.com') {
task.description = 'Issue Type: ' + issueType + '\nUnable to Login to access.fnf.com: ' + current.variables.unable_to_login_to_access_fnf_com.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Printer or Copier Problem') {
task.description = 'Issue Type: ' + issueType + '\nPrinter or Copier Problem: ' + current.variables.printer_copier_problem.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Application Specific Issue') {
task.description = 'Issue Type: ' + issueType + '\nApplication Specific Issue: ' + current.variables.app_specific_issue.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Desk Phone Issue') {
task.description = 'Issue Type: ' + issueType + '\nDesk Phone Issue: ' + current.variables.desk_phone_issue.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Wi-Fi Issue') {
task.description = 'Issue Type: ' + issueType + '\nWi-Fi Issue: ' + current.variables.wifi.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Mobile Device Issue (cell phone, ipad, tablet)') {
task.description = 'Issue Type: ' + issueType + '\nMobile Device Issue (cell phone, ipad, tablet): ' + current.variables.mobile_device.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'VPN Issue') {
task.description = 'Issue Type: ' + issueType + '\nVPN Issue: ' + current.variables.vpn.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Other Issue') {
task.description = 'Issue Type: ' + issueType + '\nAdditional Information:' + current.variables.additional_information;
}
Lots more coding then might of been necessary probably but it seems to be working for what we need it for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 11:56 AM
so it's sort of working. It's still not transferring the variables to the Incident Description field. It does however transfer it to the RITM description field.
I tried updating the scrip to:
(function executeRule(current, previous /*null when async*/) {
var variables = '';
for(var prop in current.variables) {
if(current.variables.hasOwnProperty(prop)) {
var grItemOptionM2M = new GlideRecord('sc_item_option_mtom');
grItemOptionM2M.addQuery('request_item', current.getUniqueValue());
grItemOptionM2M.addQuery('sc_item_option.item_option_new.name', prop);
grItemOptionM2M._query();
if(grItemOptionM2M._next()) {
var grItemOption = new GlideRecord('sc_item_option');
grItemOption.get(grItemOptionM2M.sc_item_option);
var variable = current.variables[prop];
variables += grItemOption.item_option_new.question_text + ': ' + variable + '\n';
}
}
}
incident.description = variables;
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 12:58 PM
So how is this workflow triggered? Thru a Catalog Item or a Record Producer?
For Catalog Items, the script will work. Variables for Catalog Items are written to 2 tables, sc_item_option and sc_item_option_mtom. Though, variables for Record Producers are written to 1 table, question_answer.
Could you verify that the variables for the Incident you are after, are created in the question_answer table?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 06:57 AM
Well the requirements changed. Now they only want to transfer the variables that have a "value" to the Description field on the Incident that is created.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 07:52 AM
Oke no worries, I can write an example, not that much work.
Though still the question, how is the Incident created? Catalog Item? Record Producer? That does make a huge difference (sc_item_option + sc_item_option_mtom vs question_answer). This is needed to know if you also want the correct labels for the variables.
If the values of the labels are already fine, you can go for the simpler scripting as mentioned in the link I posted.
Obviously, you can also go for a solution like Travers mentioned, though that offers no flexibility and you have to change the workflow every time the variables change.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 08:42 AM
I'm using the catalog item/workflow to generate the Incident. I got it to work by just coding it all out in the "Create Task" script field as follows:
task.caller_id = current.variables.requester_name.getDisplayValue();
task.short_description = current.variables.issue_type.getDisplayValue();
var issueType = current.variables.issue_type.getDisplayValue();
if (issueType == 'Outlook Problem') {
task.description = 'Issue Type: ' + issueType + '\nOutlook Problem: ' + current.variables.outlook_problem.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Computer Problem') {
task.description = 'Issue Type: ' + issueType + '\nComputer Problem: ' + current.variables.computer_problem.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Unable To Scan Docs') {
task.description = 'Issue Type: ' + issueType + '\nUnable to Scan Docs: ' + current.variables.unable_to_scan.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Internet Browser Problem') {
task.description = 'Issue Type: ' + issueType + '\nBrowser Problem: ' + current.variables.browser_problem.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Unable to Login to access.fnf.com') {
task.description = 'Issue Type: ' + issueType + '\nUnable to Login to access.fnf.com: ' + current.variables.unable_to_login_to_access_fnf_com.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Printer or Copier Problem') {
task.description = 'Issue Type: ' + issueType + '\nPrinter or Copier Problem: ' + current.variables.printer_copier_problem.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Application Specific Issue') {
task.description = 'Issue Type: ' + issueType + '\nApplication Specific Issue: ' + current.variables.app_specific_issue.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Desk Phone Issue') {
task.description = 'Issue Type: ' + issueType + '\nDesk Phone Issue: ' + current.variables.desk_phone_issue.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Wi-Fi Issue') {
task.description = 'Issue Type: ' + issueType + '\nWi-Fi Issue: ' + current.variables.wifi.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Mobile Device Issue (cell phone, ipad, tablet)') {
task.description = 'Issue Type: ' + issueType + '\nMobile Device Issue (cell phone, ipad, tablet): ' + current.variables.mobile_device.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'VPN Issue') {
task.description = 'Issue Type: ' + issueType + '\nVPN Issue: ' + current.variables.vpn.getDisplayValue() + '\nAdditional Information:' + current.variables.additional_information;
}
else if (issueType == 'Other Issue') {
task.description = 'Issue Type: ' + issueType + '\nAdditional Information:' + current.variables.additional_information;
}
Lots more coding then might of been necessary probably but it seems to be working for what we need it for.