Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get the variable value

SNOW39
Tera Expert

Hi ,

I am trying to create a variable set that is visible only on sc_task, when the task is closed, it should pull the recurring price value mentioned when the catalog item is created (sc_cat_item). How to acieve this?

1 ACCEPTED SOLUTION

Hi,

ok so in the run script after the task is complete the script is added

please find the below code

Ensure you add current.setWorkflow(false);

current.variables.recurring_price = current.cat_item.recurring_price.toString();
current.setWorkflow(false);
current.update();

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

27 REPLIES 27

Hi,

I'm thinking that with a client script you will have no access to that information so maybe better with a business rule which code should be as simple as:

current.your_variable_name = current.cat_item.recurring_price;

You'll need to specify in the conditions on "When to run" tab

 

Regards:

 

Joaquín

This didnt work for me.

Brad Bowman
Kilo Patron
Kilo Patron

To make variables in a variable set only visible on task(s), add the variable set to your catalog item, then create a UI policy to hide it on the Catalog Item view and Requested Item

find_real_file.png

Select the variable(s) in the Catalog Task definition slush bucket at the bottom, so that it/they will appear on the task.  In the workflow, after the Catalog Task, add a Run Script activity.  Your script will look something like this, depending on the variable name that you want to populate.

current.variables.recurring_price = current.cat_item.recurring_price.toString();

The value population didnt work

Add a second line to the script

current.update();

This usually isn't needed/wanted in a workflow run script, but in this case it seems to be necessary.