execute script in custom script field

NeilH2
Giga Guru

Hi

I'm writing a new application and i want to add a cutom script field to a table that a workflow will locate via a glideRecord.

The idea is the workflow will execute the script.

I'm just a little lost on how to tell ServiceNow to execute a script in a script field on a custom table.

I expected a command like "gr.u_script.run" but cant find any reference.

Any suggestions welcome

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Neil,



Check the class GlideScopedEvaluator and the method evaluateScript.



I use it all the time.


View solution in original post

11 REPLIES 11

Thanks Chuck. I figured it out. Definitely one of those face-palm moments.



I hadn't put the 'answer' or 'result' variable in the evaluator.


Once I put it in evaluator.putVariable('result', null);, it worked.




Image result for facepalm


Pretty subtle. I wouldn't have thought of that without looking at some other examples. Thanks for the info!