Logged in user should be a part of a group then only he can submit the form, other users cannot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2024 07:22 PM - edited 11-17-2024 07:22 PM
Hello Experts,
I am trying to achieve this requirement - User should not be able to submit a catalog request if he is not a part of the software group.
Tried with below On submit Client script and Script Include, but its not giving result, Can u plz help whats wrong here ?
On Submit Client Script :
function onSubmit() {
//Type appropriate comment here, and begin script below
var part = g_form.getValue('name_of_the_partition');
var reqTyp = g_form.getValue('request_type');
if ((part == 'major || 'minor') && reqTyp == "software") {
var ga = new GlideAjax('UserUtils');
ga.addParam('sysparm_name', 'checkGroupUser');
ga.getXML(checkGroupUser);
}
function checkGroupUser(response) {
var result = response.responseXML.documentElement.getAttribute("answer");
if (result == 'true') {
return true;
} else {
g_form.addErrorMessage("User not eligible to submit the form");
return false;
}
}
}
var UserUtils = Class.create();
UserUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkGroupUser: function() {
return gs.getUser().isMemberOf('TMG Catalog Users');
},
type: 'UserUtils'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2024 09:45 PM
You can check the Advanced checkbox and write the script to check for the condition within this. Refer https://www.servicenow.com/community/hrsd-forum/how-to-create-user-criteria-with-the-script-to-check...
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2024 09:54 PM
Could you help me with the query script on how to check the variables request type, part and the group user condition in User criteria, the one you shared is not relevant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2024 09:56 PM
I observed an issue with your Script Include. You are passing the group name instead of the group sys_id. Replace the group name "TMG Catalog Users" with the sys_id of this group and retry. It should work.
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2024 10:01 PM
It tried, it made no difference @Amit Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2024 09:31 PM - edited 11-17-2024 09:51 PM