How to use variables in incident task?

Sisozuki1
Kilo Contributor

I want to use variables editor such as sc_task on incident task.

To display variables field on incident task, I made ui formatter for incident task like Incident  variable editor and that field was successed to display by generating incident task directly with record producer.

But, I have no idea to display specific variables by Workflow activity like "Catalog Task". Does anyone know how to do that?

If that was possible, Are variables on incident task avaiable in list filter condition  and WF activity (like "wait for condition," "set value")?

4 REPLIES 4

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

it seems possible, just go in the WF activity setting, extend the Add variable section and select the proper one (see image below).

Have a look also to this documentation, it might help you to fit your need.

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

 

find_real_file.png

Sisozuki1
Kilo Contributor

Hi Alberto!

Thanks for reply.

 

I think "Catalog task" Activity can make only to "sc_task" table record and that activity can be used on sc_req_item only.

Is it wrong what I said?

 

I want to set variables to "incident_task".

Moedeb
Tera Guru

I wanted to do something similar myself, however wasn't able to specifically show the variables, so I found the best way was to work around it and display all my variable questions and answers in a formatted way in the description field.

 

So I added the following to the record producer script:

var isMobile = GlideMobileExtensions.getDeviceType() == 'm';
var link = isMobile ? '#/!list/incident/q:active=true%5Ecaller_id=javascript:gs.user_id()%5EEQ' : 'home.do';

var linkLbl = isMobile ? "List" : "Homepage";
var br = '<br/>';
var linkURL = '<a href="' + link + '">' + gs.getMessage(linkLbl) + '</a>';
var msgArgs = [br, linkURL];

var info = gs.getMessage("This incident was opened on your behalf", msgArgs);
	
	gs.addInfoMessage(info);
	
	
	current.caller_id = gs.getUserID();
	
	current.short_description = "WHATEVER YOU WANT GOES HERE";
	var descriptionarray;                               //Name of the array can be whatever you like
	descriptionarray = producer.variable1.getGlideObject().getQuestion().getLabel() + " " + producer.variable1 + "\n" + "\n";
	descriptionarray += producer.variable2.getGlideObject().getQuestion().getLabel() + " " + producer.variable2 + "\n" + "\n";
	
	
	if (producer.variable2 == 'Yes')                   //This is if you have any variables only being shown based on an earlier response.
		descriptionarray += producer.variable3.getGlideObject().getQuestion().getLabel() + " " + producer.variable3 + "\n" + "\n";
	else
		descriptionarray = descriptionarray;	
	current.description = descriptionarray;           //Set the description field to equal the array value

Hope this helps 🙂

vitmanov
Kilo Explorer

If selected, the workflow activity waits for the task to complete before continuing. If cleared, the task is created but the workflow proceeds.