How can you show a variable from a catalog item on an Incident or Incident Task

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2014 11:55 AM
Can someone tell me the easiest way to show a variable from a catalog item on an Incident or Incident task. Do I need to do a catalog UI policy with or without scripts? Please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2014 12:05 PM
Are you trying to create an incident from a catalog item?
If so, I have to ask if you considered using a record producer instead (it's quite a bit easier, but lacks all of perks that come with the catalog, approvals, tasks etc.)
Otherwise, I've found the best way to pass a value from a cat item variable into say an incident would be in the workflow. You can add a run script that queries whatever table you want and pass the values that way...
Here's an example of a run script I put in a workflow that creates a user from variables on the cat item. You could re-purpose this to write to an incident record and switch around the variables.
//Query the sys_user table and create a new user with the information from Add User cat item.
createuser();
function createuser() {
var gr = new GlideRecord('sys_user'); //<---Table
gr.initialize();
gr.first_name = current.variables.u_first_name; //<--gr.(field on table) current.(variable on cat item).
gr.middle_name = current.variables.u_middle_initial;
gr.last_name = current.variables.u_last_name;
gr.employee_number = current.variables.u_emp_id_num.getDisplayValue(); //<---use this if you want to pass the value and not the sys_id of a ref variable.
gr.location = current.variables.u_location;
gr.manager = current.variables.u_manager;
gr.phone = current.variables.u_phone;
gr.insert();
gs.log('ADD USER Activity 2: New User is ' + gr.name , 'Add User Workflow');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2014 12:28 PM
No David. I have a record producer via the ESS portal which automatically opens an incident ticket after submission. But my issue is there are some variables within that ESS form that I want to filter over to the incident ticket after submission. Hope that clarifies what I am trying to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2014 07:22 AM
As David mentioned in his reply - it is done via a script. The basic idea is as follows:
1. Do the GlideRecord on the Incident table to find the INC record(s) you want to update
2. Update the field in that incident record with the variables, for example:
incRecs.work_notes = current.variables.myVariable1; // current being the current record of the RITM
incRecs.update();
You can also use this approach in a Background script to update existing Incident records. The difference is you would also do a GlideRecord on sc_req_item.
Aditya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2014 07:31 AM
Excellent,
So in the record producer, the way it works is that any fields that are exactly a match to the table you point the producer at go in automatically. For example, if you have a variable on the RP called "caller_id" and you point at the incident table, when you submit the record producer, it will try and pass the sys_id of the caller_id variable into the caller_id field on the incident.
However! If you need to pass a value from a variable that isn't the same name, you put that in the script section on the record producer. Here's an example of a link I made from a RP to incident.
gs.include("FormInfoHeader"); | |
var fi = new FormInfoHeader(); | |
var s = 'Thank you for submitting your request.<br/>'; | |
s += 'The IT department will contact you if they need any further information.<br/>'; | |
s += 'You can track status from the <a href="home.do" class="breadcrumb" >Homepage</a> .<br/>'; | |
fi.addMessage(s); | |
current.u_customer = producer.caller_id; | |
current.u_caller_id = producer.caller_id | |
current.u_room = producer.Room; | |
current.u_floor = producer.floor; | |
current.location = producer.Location; | |
current.description = producer.comments; | |
current.u_phone = producer.phone; | |
current.assignment_group.setDisplayValue('Service Desk'); | |
current.u_application = producer.app; | |
current.u_type.setValue(4); | |
//producer.redirect = 'sc_request.do?sys_id=' + current.sys_id | |
producer.redirect="home.do"; |
Where you see current. that's the field on the table you're aiming at. Where you see producer. that's the record producer variable.
I kept some other code to help you along if you need to customize it, for example, producer.redirect will send you to different places after you submit the record producer...Right now I've configured it to go back to the home page. But I commented out another where you can go to the request that gets made afterwards...
Hope this helps!