Workflow Runscript

kamal11
Giga Expert

Hi all,

I have a requirement where in I need to auto populate a certain variable value on the task based upon the value from the asset table.

The display name of the asset has to be populated on the variable of task, once the purchase order is received of the procurement.

To achieve this I have created a run script before the task creation in the workflow,

find_real_file.png

The run script is below,

var gr = new GlideRecord('alm_asset');

  gr.addQuery('request_line',current.sys_id);

  gr.query();

  if(gr.next())

  {

current.variable_pool.variable to be updated on task = gr.dispay_name.getDisplayValue();

}

Here the variable to be updated on the task is in the variable set, hence I have put in variable_pool in the script.

The variable we are trying to update is also present on the RITM and also on the catalog task.

But the run script is not updating the variable on the task. Can anyone help me in finding what else needed to be done on this requirement.

Thanks,

Kamal

11 REPLIES 11

Deepak Kumar5
Kilo Sage

You can use script in your task activity.


Set task field value after getting the data from glide.


task.field_name = current.variables.variable_name;


Deepak Kumar5
Kilo Sage

To pass variable value from one activity to another, You have to use workflow scratchpad variable.


HI Deepak,



Variable in which we need to pull the asset name is a variable from the variable set of the catalog item. It is NOT THE TASK FIELD.



Can you let me know how can we achieve this.



Thanks.


I tried the below script on my demo instance and it worked fine!




var gr = new GlideRecord('alm_asset');


  gr.addQuery('request_line',current.sys_id);


  gr.query();


  if(gr.next())


  {



current.variable_pool.variablename = gr.display_name;


}



Regards,


Vaibhav



Mark Correct /Helpful /Like based on the effect of response.