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

Change Task in Workflow

leahp
Kilo Guru

I have a workflow that will create a change request when a catalog task closes.  In addition to the change request, I need for it to open a change task, propagating specific information from the change request to the change task, specifically the fields listed below:

 

Configuration Item

Change Request #

Company

Short Description

 Assignment Group

Assigned To

 

Set due date to 5 days out. 

Below is script I have.  The only thing working is the due date.

 

task.change_request = current.getValue('sys_id');
task.cmdb_ci = current.getValue('cmdb_ci');
task.assignment_group = current.assignment_group;
task.assigned_to = current.getValue('assigned_to');
task.short_desccription = current.short_descrirption;
task.company = current.getValue('company');
task.u_category = 'Hardware';

 

thoughts?

 
1 ACCEPTED SOLUTION

scott barnard1
Kilo Sage

Hi leahp

 

In the create change task choose set values and set your state and initial assignment group etc then go to the advanced section

Tick the advanced box

Add the line

 

workflow.scratchpad.sys_id = task.sys_id;

 

 

What this does is passes the sysID of the created change to the scratchpad

Then go to your change task script and in the advanced section add

 

var sys_id = workflow.scratchpad.sys_id;


task.change_request = sys_id;

 

What this does is retrieves the sysID of the Change you created and sets the change task change_request field with it.

 

I mocked this up like yours and it creates fine

 

Hope this helps

 

 

View solution in original post

7 REPLIES 7

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Leahp,

 

I'm assuming the workflow is defined on the "sc_task" table. If yes then in this case to pass the change request values to task, you will have to first query the change request record via GlideRecord and then set the values in change task.

 

Thanks,

Pradeep Sharma

The workflow is against a RITM  User submits a RITM, which generates a catalog task.  Once catalog task is closed, create a change request and a change task.  That is where I am running into trouble.

 

 

 

scott barnard1
Kilo Sage

Hi leahp

Do you want to create a change every time you close an item? Have you considered a simple ui action on the catalog task form if it's discretionary?

But sticking with the workflow for now could you do a screenie of your workflow, just need to understand what objects you are using to create the various records

Assume you are doing create task for the catalog task then 1 maybe 2 run scripts that generate the other records and link them?

Pop the various scripts in too so we can see what you're doing

Regards

 

 

leahp
Kilo Guru

Here is a screenshot.  User submits a catalog item.  A Catalog task is created and assigned to a group.  When that task closes, we need to have a change request and a change task (there could be more than one based on inputs - I am just trying to get one to work).  I would like for the change task to be populated with information from the change request (short description, assignment group, company, configuration item to name a few

 

find_real_file.png