Evaluating condition fields

Mark Roethof
Tera Patron
Tera Patron

Hi all,

Just for testing purposes, I'm wondering how to evaluate condition fields. Specifically, if a user would have access based on the condition field.
For example, a condition field which contains:

 

(function execute() {

    return false;

})()

Or:

 

(function execute() {

    var incidentGr = new GlideRecord('incident');

    return incidentGr.canWrite();

})()

How can I check, if the condition in the condition field, evaluates to true for the logged in user? Any ideas?

 

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

1 ACCEPTED SOLUTION

GlideRhinoHelper is not allowed in scoped applications.

just another way,, can you try to write one script include in global scope and then make the scope for all
application scope and then try to call it , see if that is working or not. i think this way it will work.

View solution in original post

9 REPLIES 9

Sagar Agarwal
Mega Guru

Hi,

 

Your condition fields are executed on server side and they expect true or false to allow whatever there purpose is.

Not sure why would someone use IIFE in condition field however, it can be used.

 

For evaluation, I'll suggest to either add info messages or add logs in sytem to evaluate whether your condition script returned true or not.

 

Thanks 

For example, Virtual Agent topics contain such conditions. Though, If I would like to present a list of topics to a user, I would only like to present the topics the user has access to. Therefor I need to evaluate these conditions, which are stored in a field. Though, how?

I know within Topics there is a vaSystem property. Though, this concerns using this in a Business Rule for example where obviously we don't have the vaSystem property available.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

I am able to evaluate most conditions in the field with below code. Though not all unfortunately, also not Scoped 😞

GlideRhinoHelper.evaluateAsBoolean(gr.applicability)

Any ideas?

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

did you try to run this in your background script ? if yes what is the result it's giving you ?