Script User Criteria in Scope App for Session User

Meloper
Kilo Sage

I saw in the Latest criterias that we need to "return" the answer.

Also i saw that getRecord() and getUser() will not work in scope.

 

/** Scripted User Criteria is not cached, and evaluated everytime, so performance is dependent on the script.
* Populate `answer` with true/false or evaluate to true/false
* The script is evaluated in the scope the user criteria is defined
* Don't use `current` in the script or populate the variable
* Don't use `gs.getUser()` or  `gs.getUserID()`,
* instead use `user_id` which contains the user sys_id against whom the evaluation is happening.
*/

 

1. do we really need to populate the answer or is this a recommendation? Because i see many old scipts which seems to be working but doesn´t populate the answer

 

2. how can i write the script to check if the current user has the Value "XY" ind Custom Field "ABC" on sys_user tabele in the User criteria script?

i guess something like this?

 

function checkAccess(){

var grUserSession = new GlideRecord('sys_user');
if (grUserSession.get(user_id)) {
return grUserSession.ABC
}

answer = checkAccess();

 

 

0 REPLIES 0