Set value variable task in a workflow

ggggasgasgasgas
Kilo Contributor

Hi all.

 

I have a task in a workflow with a variable. If you select "NO" in this variable, you go to another task and when you close this task , you back to the other task and in this moment i want to restart the value of this variable but i dont know how.

find_real_file.png

 

The cuestion is, how can I set the value of a catalog task variable?

 

Thanks

1 ACCEPTED SOLUTION

Sebastian R_
Kilo Sage

Because the variables in the catalog task are shared from the request item, you can simply change the variable on the request item.

Therefore you need a Run Script with something similiar to:

// current is the GlideRecord referencing the Requested Item
current.variables.my_variable = 'new value';
current.update();

View solution in original post

5 REPLIES 5

Sebastian R_
Kilo Sage

Because the variables in the catalog task are shared from the request item, you can simply change the variable on the request item.

Therefore you need a Run Script with something similiar to:

// current is the GlideRecord referencing the Requested Item
current.variables.my_variable = 'new value';
current.update();

Hello, I am currently doing a workflow and I am placing an approver per group of assignments.

 

But now I have to do another one, with a RITM variable, but in the advanced options, I don't get the option to add the variable.

How do you recommend doing the code, or how can I visualize the variable I require.

 

Thanks.

 

Michael Jones -
Giga Sage

The variables in a catalog task are actually the variables in the RITM. 

When you want to change a value of a variable in the workflow, all you need to do is call something like this: 

current.variables.<your_variable_name> = 'value';

If you do this inside of a task script you don't need to call anything like current.update() for the change to be saved, in fact,  you want to avoid current.update() in a workflow as it can cause some strange behavior. 

If you did need to use current.update(), you'd probably want to use:

current.setWorkflow(false);

current.update();

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Michael Jones -
Giga Sage

Sorry, yes as Sebastian has already pointed out (didn't see his reply until I posted mine). The only addition is, again, you don't need to use current.update() if you set this inside of the workflow. 

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!