Script type dictionary entry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2012 06:12 AM
Hi,
Has anybody used dictionary entry of "script" type. If yes, Please tell me how do i use this dictionary entry?. How can we execute the code written in this dictionary entry?.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2012 11:27 AM
You can create fields of type "script" if you want, but they certainly will not be run anywhere. You cannot change the basic behavior of the SN platform like that, as it knows what tables contains code that it can run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2012 03:09 PM
You can evaluate/execute a script in a field with Evaluator.evaluateString(string)
e.g., the following will print a line in the log:
Packages.com.glide.script.Evaluator.evaluateString("gs.log('hey there');");
Eventually when Packages calls are no longer allowed, this line would have to be changed to the following (but the following line won't work until the Calgary release):
GlideEvaluator.evaluateString("gs.print('heya');");
I know of one customer who created a field to store scripts, then had a UI Action on the form that used Evaluator.evaluateString to run the script. Something like the following:
Packages.com.glide.script.Evaluator.evaluateString(current.u_my_custom_script_field);
I'm sure I don't have to say that it would be extremely ill-advised to make something like this available to non-admins 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2012 04:11 AM
Thanks a lot. i have been searching for that since a long time. Can you also tell me like what will 'current' refers to in these types of script. For example if i write
current.u_table == 'sc_request' // where u_table is a field on my table which references to all the tables.
will it refer to the current record? or the behaviour is different?.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2012 08:21 AM
Pretty sure "current" won't exist. In things like Business Rules, "current" is a GlideRecord object provided by the code running the business rules, set up to be the record the rules are running against. For an arbitrary script in a text field, there's nothing that will do that.
If you described in excruciating detail what you're trying to implement, what you want it to do and when, etc., someone in this community might have an idea of how you might go about it.