Choose ticket type from Record Producer

elemonnier
Tera Expert

We recently had a need to allow the user to select the ticket type from within the Record Producer form. You see, we use Incidents specifically for when there was a problem with something that had worked previously, anything else comes in as another ticket type. This allows for stricter SLAs on Incident and easier reporting.

The problem we came across was how to select the table from the questions being answered on the form. I looked into Wizards but with the time needed to configure each one, I found that using Record Producer would be more efficient. The trick was to configure the Record Producer to abort right off the bat and then use the producer variables to create the ticket of your choice.

1. Create a Record Producer on the Service Catalog with the Table Name: Global [global].
2. Add common fields: requested_for, short_description, description
2. Add a Multiple Choice field (ticket_type) that has values of incident and another ticket type.
3. Add the following script:

Script:



current.setAbortAction(true);//cancel creation of global record

if(producer.ticket_type == 'incident'){
var newTask = new GlideRecord('incident');
newTask.initialize();
newTask.caller_id = producer.requested_for;
newTask.short_description = producer.short_description;
newTask.description = producer.description;
var newID = newTask.insert();
}else{
var newTask = new GlideRecord('u_ticket');
newTask.initialize();
newTask.u_requested_by = producer.requested_for;
newTask.short_description = producer.short_description;
newTask.description = producer.description;
var newID = newTask.insert();
}

2 REPLIES 2

kabirsu
Kilo Explorer

Hi,



Only issue with this approach is that you cannot associate a variable editor on the redirect table i.e. 'u_ticket'. Tried doing the normal way by adding a formatter but it doesnt work. Any thoughts?



Thanks.


You're right, this method will only let you build basic tickets without the formatter. You'll have to take the response from these items and place them in the description. I haven't found a way to add to the variable pool after the initial creation.