Alternative for eval() in servicenow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2021 09:13 AM
Hi All,
I need to replace the eval() with glide script evaluator and below is the Script Include used in a Report to pull the records.
Script Include:
function CRA_Use(js, arg) {
var grq_ps = new GlideRecord('pa_scripts');
grq_ps.addQuery('name', js);
grq_ps.query();
if(grq_ps.next()) {
eval(grq_ps.script);
if(typeof CRA_JSF === 'function') {
if(typeof arg === 'undefined') { return CRA_JSF(); } else { return CRA_JSF(arg); }
} else if(typeof CRA_JSC === 'function') {
if(typeof arg === 'undefined') { return CRA_JSC(); } else { return CRA_JSC(arg); }
} else if(typeof CRA_JSO === 'function') {
if(typeof arg === 'undefined') { CRA_JSO(); } else { CRA_JSO(arg); }
}
}
}
Can anyone guide me in modifying the above script.
Thanks in Advance,
Shilpa.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2021 05:58 AM
Hi,
Did you check what is there in script?
check this link where I have shared an example
How to pass "current" dynamically within GlideEvaluator.evaluateString() as parameter..
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2021 01:00 AM
Hi
The script is returning sysid's of recods.But when i am trying the above code I am getting as undefined.
Thanks,
Shilpa.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2021 01:37 AM
Please check the working example link I shared and try to enhance as per that
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 12:36 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2021 05:45 AM
Please refer to this API document for more information.