The CreatorCon Call for Content is officially open! Get started here.

Map all catalog item variables to Description field on Incident

booher04
Tera Guru

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. 

1 ACCEPTED SOLUTION

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.

View solution in original post

14 REPLIES 14

Ah oke good to hear you came up with a solution.

Could you mark your own answer as correct if you feel so. Or mark mine as correct (or helpful).

This will help others who are looking for a similar solution. Also marking an answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Will do.. I was hoping to have a "Run Script" or something that was in one place that I could use instead of having to put code into every "create task" workflow activity, but I can't get this script to work that way.  Thanks for all your help with this.

Run Script as in you only have to script this once? Still would be possible. And then the generated description should be passed with scratchpad to the Task steps.

So if you build a description variable, you could do something like:

workflow.scratchpad.description = your_var_with_all_description_content;

That same workflow.scratchpad.description will then be available later on in your workflow. So efficient scripting if you would need this in multiple Task steps.

In your task script field you could to something like:

task.description = workflow.scratchpad.description;

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Travers M
Mega Guru

So I have this in the script of a record producer that takes the variables from the record producer and adds them all to the description field on the request.  You're going to need to label your variables accordingly but this may be a good start.   If this isn't what you're looking for, I apologize in advance.

 

current.description = "Request Summary" + "\n\nName of Primary Driver: " + producer.primary_driver + "\nNumber of Adults: " + producer.adult_number + "\nReason for Trip: " + producer.trip_reason + "\nDestination for Trip: " + producer.trip_destination + "\nVehicle Number: " + producer.u_vehicle_number +  "\nOffice Location: " + producer.office_location + "\nDate and Time for Vehicle Pick Up: " + producer.pick_up + "\nDate and Time for Vehicle Return: " + producer.return_date  + "\nAcceptable Use Policy: " + producer.acceptable_use;

so I should of gave a little more details behind what I have setup.

I have a workflow setup that will direct the flow into 2 different paths. If the user selects "Issue" it will go to the path that uses a "Create Task" activity that creates an Incident.  If they select "Request" it will go to the path that creates a "Catalog Task".  I have used what you described in the past for my record producers.

 

find_real_file.png