Restrict users from raising request when requested for user doesn't have Manager for their profile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 08:36 AM
How can we restrict users from raising a request from portal when the Requested for user doesn't have Manager associated against their profile.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2023 12:36 AM
Hi @User351756 ,
Write a catalog client script type "onSubmit" and create a script include which glides the user table and check whether particular user has manager. if needed also check whether the user is part of any group. If user does not have manager, then throw an error message and return false.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 02:44 AM
Hi Neeraj,
I have tried creating script include and catalog client script. The error message is showing up. However, the request is still getting created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 02:58 AM
Hi @User351756 ,
Can you check what script include returning the value. Its better to return the toString value from the script include and in Client script remove line no 9 and in 10 line write "return false" instead of just return;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 05:53 AM
Hi Neeraj,
I have updated client script as suggested, It dint help. Request is still getting created.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 02:38 AM - edited 05-02-2023 02:39 AM
Hi @User351756
For an onSubmit client script, you need to use getXMLWait. getXML/getXMLAnswer won't wait until the response is received from the script include.
Try this:
function onSubmit() {
var ga = new GlideAjax('Requestedformanager');
ga.addParam('sysparm_name', "RequestedformanagerPresent");
ga.addParam('sysparm_userID', g_form.getValue ('Requested_For'));
ga.getXMLWait();
var answer = ga.getAnswer();
if (answer == 'true') {
g_form.addErrorMessage('Selected User does not have Manager and is not a VIP user');
return false;
} else {
return true;
}
}