Populating Config Item variable into tasks

JSSNow
Tera Contributor

Hi,

We have a variable on a form that asks for the relevant CI name. 

Whilst this variable shows in RITMs/ Tasks this doesn't automatically populate through to the existing inbuilt CI field which can be used in views / reporting.

We use the script below in a workflow to set this for RITM'S (and a similar script to pass  through the requestor)

// Set CI
current.configuration_item = current.variables.configuration_item_ci_name_from_form;

I have ben unable to replicate this for tasks though and I'd like to be able to do so, this is in order that teams purely working on tasks can see which CI they have in their queue at a glance.

Does anyone have any ideas? simply lifting and shifting the script into a workflow task doesn't work.

Thanks

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you must be using catalog task activity in workflow to create task

there you can use advanced script and set it

The field on sc_task is cmdb_ci

task.cmdb_ci = current.variables.configuration_item_ci_name_from_form;

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Mahak2
Kilo Guru

Hello

You can populate the CI field on your Requested Item in a "Run Script" workflow activity with the following code:

current.configuration_item = current.variables.v_configuration_item;

current.update();

"configuration_item" being the name of the field on the RITM form

"v_configuration_item" being the name of the variable on the Catalog Item form

Thanks

Please mark my response as helpful and correct as applicable.

For task use this.

var grRequest = new GlideRecord('sc_req_item);
if(grRequest.get('sys_id',current.request)){
task.cmdb_ci = grRequest.cmdb_ci;
}

Thanks

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you must be using catalog task activity in workflow to create task

there you can use advanced script and set it

The field on sc_task is cmdb_ci

task.cmdb_ci = current.variables.configuration_item_ci_name_from_form;

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

JSSNow
Tera Contributor

Thanks, will do some testing