- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2024 02:07 AM
User should not be able to submit catalog request when Req type = Software and if he is not a part of a particular group. He should get an error message while submitting that "Not eligible for form submission".
Kindly help how to achieve this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2025 02:57 AM
you can do this
1) create a string variable with highest order, set the flag in default value something like this, then hide this variable so that it doesn't show to user
javascript: gs.getUser().isMemberOf('Group ABC'); // give the group name here
2) use onSubmit catalog client script to stop the submission
function onSubmit() {
//Type appropriate comment here, and begin script below
var reqTyp = g_form.getValue('request_type');
if (reqTyp == 'Software' && g_form.getValue('hiddenVariable').toString() == 'true') {
alert('You cannot submit this request');
return false;
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2024 02:49 AM
Hi @Mishu ,
You can write onSubmit catalog client script with below code
Client script code
function onSubmit() {
//Type appropriate comment here, and begin script below
var reqTyp = g_form.getValue('request_type');
if(reqTyp == 'Software'){
var ga = new GlideAjax('UserUtils');
ga.addParam('sysparm_name', 'checkGroupUser');
ga.getXML(checkGroupUser);
function ValidatecheckGroupUserVipUser(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer=='true')
return false;
}
}
}
Server side code: create a script include with name UserUtils with client callable.
var UserUtils = Class.create();
UserUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkGroupUser: function() {
return gs.getUser().isMemberOf('Your Group Name');
},
type: 'UserUtils'
});
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2024 04:46 AM
User is still able to submit the form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2025 02:57 AM
you can do this
1) create a string variable with highest order, set the flag in default value something like this, then hide this variable so that it doesn't show to user
javascript: gs.getUser().isMemberOf('Group ABC'); // give the group name here
2) use onSubmit catalog client script to stop the submission
function onSubmit() {
//Type appropriate comment here, and begin script below
var reqTyp = g_form.getValue('request_type');
if (reqTyp == 'Software' && g_form.getValue('hiddenVariable').toString() == 'true') {
alert('You cannot submit this request');
return false;
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2025 08:04 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader