Restrict users from raising request when requested for user doesn't have Manager for their profile

User351756
Giga Expert

How can we restrict users from raising a request from portal when the Requested for user doesn't have Manager associated against their profile. 

10 REPLIES 10

Neeraj_27
Tera Guru

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.

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.

User351756_0-1682674963524.pngUser351756_1-1682675002550.png

 

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;

Hi Neeraj,

 

I have updated client script as suggested, It dint help. Request is still getting created.

 

Thanks

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;
  }
}