Restricting form submission for set of users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2023 04:46 AM
Hi All,
I have a requirement on a form when the 'Requested For' user tries submitting the form if he has records in a custom table (i.e requested for = assigned to in custom table) then the user should not be able to submit the form.
I have configured a catalog 'On submit' client script and a 'Script include' for the same.
But here in both the scenarios the user is not able to submit. can someone pls help
1) client script
2)Script Include
User: function() {
var add={};
var gr = new GlideRecord('CustomTable');
var usr = this.getParameter('sysparm_reqfor');
gr.addQuery('u_assigned_to', usr);
gr.query();
if(gr.next()){
return 'valid';
}
else{
return 'invalid';
}
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2023 11:35 PM
Hi @AnveshKumar M ,
I need the code working for both Portal and Platform UI.
I got this error when i tried testing from platform.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2023 11:17 PM
why not handle the validation using onChange + GlideAjax?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2023 11:45 PM
Hi @Ankur Bawiskar ,
I want this for both onChange and onSubmit....
I am not sure if we can restrict form submission using OnChange client script. If there is a way then please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2023 12:20 AM
if the validation fails you can clear the variable and make it mandatory
in this way user cannot submit the form unless validation passes
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