additional task to a workflow

levino
Giga Guru

Hi Experts

 

i have attached a snippet of my current workflow which calls a REST API, it works as expected.

 

i have a additional requirement to ,create a task and assign it to a fulfilment group.

 

i do not want to change the existing workflow as its working as expected.

 

please guide me thru creating a task , not sure how to get the values to populate into the task

 

i can provide some more info if needed

 

Thank You

Levino

11 REPLIES 11

Hi @levino 

 

It will be Create catalog task.

Ok ..can you let me know which field on catalog task you want to update from this run script.

& what value from run script you want to update on task.

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Hi Vishal 

i just need to pass the below variables which have been selected on the catalog item to the task.

i have put catalog task activity after the REST - SUCCESS node in the workflow, it says its running creating a task but does not actually create a task

Thanks

Levino

 

workflow.scratchpad.ReferenceNumber = current.number;
if (current.variables.url_of_extension_from_the_chrome_web_store){ 
	workflow.scratchpad.ChromeExtensionURL = current.variables.url_of_extension_from_the_chrome_web_store.toString(); 
} else {
	workflow.scratchpad.ChromeExtensionURL = '';
}

if (current.variables.url_of_extension_from_the_firefox_web_store){ 
	workflow.scratchpad.FireFoxExtensionURL = current.variables.url_of_extension_from_the_firefox_web_store.toString(); 
} else {
	workflow.scratchpad.FireFoxExtensionURL = '';
}

var requested_by = current.variables.requested_by;
var requestorByRecord = new GlideRecord('sys_user');
requestorByRecord.addQuery('sys_id', requested_by);
requestorByRecord.query();
if (requestorByRecord.next()){
	workflow.scratchpad.RequestedByEmail = requestorByRecord.email;
}

var gr = new GlideRecord('sys_rest_message');
gr.addQuery('name', 'MiB SC-Orch Job Management');
gr.query();

if (gr.next()){
	var restMessage = gr.getUniqueValue();
	var grHttpMethod = new GlideRecord('sys_rest_message_fn');
	grHttpMethod.addQuery('rest_message', restMessage);
	grHttpMethod.addQuery('function_name',current.cat_item.name);
	grHttpMethod.query();
	
	if (grHttpMethod.next()){
		workflow.scratchpad.message = grHttpMethod.sys_id;
	}
}

var time = new GlideDateTime().getNumericValue();

workflow.info(time + " ref number: " + workflow.scratchpad.ReferenceNumber);
workflow.info(time + " Chrome extension URL is: "  + workflow.scratchpad.ChromeExtensionURL);
workflow.info(time + " Firefox extension URL is: " + workflow.scratchpad.FireFoxExtensionURL);
workflow.info(time + " Requested by Email is: " + workflow.scratchpad.RequestedByEmail);
workflow.info(time + " HTTP method is: " + workflow.scratchpad.message);