Setting sc_task variables via workflow

Whitney3
Tera Contributor

I'm new to ServiceNow development and I am working on building out our first Service Catalog. When an item is ordered and the task generated on the sc_task table, I'm trying to set the Business Service and Catalog Item fields via workflow.

I have tried setting via script:

task.business_service = "Benefits";

task.cmdb_id = current.cat_item;

And via the Set Values options were I do get to select Benefits from the Business Service Dropdown. However, the field never gets populated and adding this step seems to cause the workflow to halt. (Also I want to be able to reuse this workflow for all items in the category Benefits so I need to be able to set the CI dynamically.)

It seems like there should be a very easy way to do this but my searches are turning up empty. Is there anyone who could point me in the right direction?

Many Thanks!

 

3 REPLIES 3

Whitney3
Tera Contributor

Update - I can now get the Business Service to populate via Set Values (human error on that one). Still stuck on the CI which I need to match with the Item Name.

 

Thanks!

Are you trying to set variables on the workflow task via a run script in the workflow? Or just setting the variables on the task in the workflow itself?  Need some screenshots of where you are trying to do this.


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

I want to be able to reuse the workflow for all "Benefits" items. Therefore the CI needs to be entered based on the name of the Service Catalog item. I am therefor trying to set the value via script in the "Advanced Script" section of the Catalog Item task.

find_real_file.png

 

Is this what you needed?