Any insights on what Scriptlet Function is?

Community Alums
Not applicable

Hello guys,

just came across scriptlet_function table. Anyone seen that already? What it does and how to use it? If GlideScriptEvaluator() is the way to use it - why is this needed ? 

Any insights are much appreciated!

 

Cheers,

Joro

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Joro, scriplets are functionality added in Paris that give you a scripting environment that doesn't load the ordinary scripting scopes you would have in a server-side script. It is isolated from script includes and most APIs and just has access to the vanilla rhino javascript. 

think its purpose is to support some future functionality, and I don't think it's very useful for customer/partner developers in its Paris version.

View solution in original post

5 REPLIES 5

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Joro, scriplets are functionality added in Paris that give you a scripting environment that doesn't load the ordinary scripting scopes you would have in a server-side script. It is isolated from script includes and most APIs and just has access to the vanilla rhino javascript. 

think its purpose is to support some future functionality, and I don't think it's very useful for customer/partner developers in its Paris version.

Community Alums
Not applicable

Hey Brad,

yes, you are correct - no SI,etc allowed, only glide system objects. So I would say you are correct - its for some unknown future use 😄

 

Thanks!

Joro

Community Alums
Not applicable

Okay,

I think I got it. As of the licensing cost and stuff, if you create a new custom field (in our case type Script) you should pay for that. With this table, you just add records in there and then you call GlideScriptEvaluator(). Then you dont have to pay for scripted fields - if you meed to have such one.

 

Example:

Create record "test" and in script field add "gs.addErrorMessage("TEST");

SAve the record.

Note its sys_id (or query by name)

 

In background script add :

var evaluator = new GlideScopedEvaluator(); 
gr = new GlideRecord('sys_scriptlet_function'); 
gr.get('<sys_id>');

gs.info(evaluator.evaluateScript(gr, 'script'));

 

Then execute and the message will be seen

 

Cheers,

Joro

Hi Joro, with GlideScopedEvaluator you can evaluate any script that exists in a script field, but I don't believe that is the purpose of this new table. I would just use a Script Include or something similar.