- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 04:47 AM
var userCriterias = ['6b6df061ff2121009b20ffffffffff44','0b5b0e6453631300afffddeeff7b1201']; var userMatches = sn_uc.UserCriteriaLoader.userMatches(gs.getUserID(), userCriterias); gs.info(userMatches);
Trying to implement this validation in a catalog to check if the user has met the user criteria for which I am using an onload script to retrieve the userID and passing it to server side script through glideajax. Which returns back null value all the time. Have put on logs to see if the right values are passed on, which seems to be good. Let me know if any changes to be made with the code.
Client script:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 05:49 AM
Please update your script include code like below:
var UserCriteriaValidator = Class.create();
UserCriteriaValidator.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkUserMatches: function () {
var userID = this.getParameter('sysparm_userID');
var userCriterias = [];
userCriterias.push(this.getParameter('sysparm_userCriterias'));
// Check if the user matches the given criteria
var check = sn_uc.UserCriteriaLoader.userMatches(userID, userCriterias);
// Return the result
return check.toString();
},
type: 'UserCriteriaValidator'
});
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 04:52 AM
Hi @imran rasheed ,
Replace your script include with below code & try
var UserCriteriaValidator = Class.create();
UserCriteriaValidator.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkUserMatches: function () {
var userID = this.getParameter('sysparm_userID');
var userCriterias = this.getParameter('sysparm_userCriterias');
// Check if the user matches the given criteria
var check = sn_uc.UserCriteriaLoader().userMatches(userID, userCriterias);
// Return the result
return check;
},
type: 'UserCriteriaValidator'
});
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 04:58 AM
Thanks for your reply Danish.
It gives the same null value. I think there is an issue while passing the user criteria.
Even in the background script run only when I pass the user criteria sys id's in an array, it works. If I pass the sys id directly, it isn't working.
var userCriterias = ['6b6df061ff2121009b20ffffffffff44','0b5b0e6453631300afffddeeff7b1201']; var userMatches = sn_uc.UserCriteriaLoader.userMatches(gs.getUserID(), userCriterias); gs.info(userMatches);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 05:16 AM - edited 12-19-2023 05:25 AM
Hi,
Please try below:
var UserCriteriaValidator = Class.create();
UserCriteriaValidator.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkUserMatches: function () {
var userID = this.getParameter('sysparm_userID');
var userCriterias = [];
userCriterias.push(this.getParameter('sysparm_userCriterias'));
// Check if the user matches the given criteria
var check = new sn_uc.UserCriteriaLoader.userMatches(userID, userCriterias);
// Return the result
return check;
},
type: 'UserCriteriaValidator'
});
Second parameter 'userCriterias' is not string, it should be of type array/list.
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 05:35 AM
It still returns null.