Run User Criteria on the basis of session URL

Harsh Ahuja
Tera Contributor

Hi Community,

I want to run Record Producer User Criteria only on the Agent Workspace & for that the below User Criteria Script has been written, but it is not running.

 

var url = gs.getProperty("glide.servlet.uri") + gs.action.getGlideURI();

var userRec = new GlideRecord("sys_user");
userRec.addEncodedQuery('location.country=INDIA^active=true');
userRec.query();
if (url.indexOf('workspace') > -1) {
if (userRec.hasNext())
answer = true;
else
answer = false;
}

 

Can you please help me to achieve this one.

 

2 REPLIES 2

Rahul Kumar17
Tera Guru

Hi @Harsh Ahuja ,

 

The script you provided checks if the URL contains the string "workspace", and if so, it checks if there is at least one active user in India, and sets the answer variable to true if there is, and false if there isn't.

To run this user criteria script on a Record Producer in the Agent Workspace, you need to configure the Record Producer to use this script as the user criteria. Here are the steps to do so:

  1. Open the Record Producer that you want to apply the user criteria to.

  2. In the form header, click the gear icon and select "Configure > Advanced" to open the Advanced Configuration dialog.

  3. In the Advanced Configuration dialog, scroll down to the "User Criteria" section.

  4. In the "User Criteria" section, select "Script" as the user criteria type.

  5. In the "User Criteria Script" field, paste the script you provided.

  6. Save the Record Producer.

Now, when a user submits a request using this Record Producer in the Agent Workspace, the user criteria script will run and determine if the request should be allowed based on the criteria you defined. If the answer variable is true, the request will be allowed. If the answer variable is false, the user will be presented with an error message and the request will not be allowed.

If this script is not working as expected, you may want to check the system logs for any errors or debug information that can help you troubleshoot the issue.

 

Thanks,

Rahul Kumar

If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar

Harsh Ahuja
Tera Contributor

Hi @Rahul Kumar17 

 

Thank you very much for your reply over my thread, I tried the same thing which has been mentioned by you. Please find below the screenshot for the same.

HarshAhuja_0-1682311834413.png

Sorry to say but still its not working.