How to include Script field

Sneha39
Mega Guru

I have plain script type field on custom table and i am using record of my custom table in workflow to create item , now i want to add script inside script type field on custom table but i am not sure how to call it in workflow.

6 REPLIES 6

Filipe Cruz
Kilo Sage
Kilo Sage

Hello Sneha,

You want to execute the script you added in your field inside the workflow, is that it?

yes @Filipe Cruz 

Hi Sneha,

So, you can run a script like this:

var param1 = current.getValue('sys_id');
var scriptResult = true;

var evaluator = new GlideScopedEvaluator();
evaluator.putVariable('param1', param1);
				
scriptResult = evaluator.evaluateScript(current, '<name_of_the_field_that_contains_the_script>', null);

 

Then, in the field that contains the script, you can use "param1" as it was declared.

This is a very powerful tool to use!!

Please, if this answer is relevant for you, please mark it as correct and helpful.

Thanks,

Filipe

@Filipe Cruz  I want it more dynamic. there are multiple scripts in my table so workflow should be able to execute all