Requester cannot be the approver at the same time(?)

Vladi1
Kilo Guru

Hello

I am looking for the alert message that would prevent self approval process in Service Catalog.

I found few scripts online how to display message (and even to clear the name in the field), but it won't break the process. The last update is that I have script that will display alert and delete the approver field regardless of the name.

 

Any advice and suggestions will be greatly appreciated.

Thank you

 

1 ACCEPTED SOLUTION

Vladi1
Kilo Guru

This is the script. Thank you Scott Peterson




function onSubmit() {


  var requester = g_form.getValue('variables.requester');


  var reqApprover   = g_form.getValue('variables.approver');


  if ( reqApprover.toString() == requester.toString() ){


  g_form.hideFieldMsg('approver', true);


  g_form.showFieldMsg('approver','Approver can not be same as the Requester!','error');


  g_form.setValue('variables.approver','');


  g_form.getControl('variables.approver').focus();  


  return false;


  }


};


View solution in original post

8 REPLIES 8

Vladi1
Kilo Guru

This is my script:


function onSubmit()   {


if(isLoading)


              return;


var approver = g_form.getValue('approver');


                              //alert('approver ==' + approver);


var requester = g_form.getValue('requester');


                              //alert('requester ==' + requester);


                                  if(approver == requester){


alert('Requester cannot be the approver at the same time.');


g_form.clearValue('approver');


                                                                  return false;


      }


jesusemelendezm
Mega Guru

Hi Vladimir, what do you want it to do when the requester is the same person that approve that specific catalog item?



Alternatives that I have seen in this case:



1) The request will get automatically approved if requester = approver.


2) If requester = approver alert requester that cannot submit request.


3) if requester = approver approval request will be sent to approver/requester direct manager.



Is that what you are looking for any of these three options?


Thanks for reply


Option #2 would work fine if I could prevent user to submit request. As I mention, I am able to create alert, but it want stop process.


Vladi1
Kilo Guru

This is the script. Thank you Scott Peterson




function onSubmit() {


  var requester = g_form.getValue('variables.requester');


  var reqApprover   = g_form.getValue('variables.approver');


  if ( reqApprover.toString() == requester.toString() ){


  g_form.hideFieldMsg('approver', true);


  g_form.showFieldMsg('approver','Approver can not be same as the Requester!','error');


  g_form.setValue('variables.approver','');


  g_form.getControl('variables.approver').focus();  


  return false;


  }


};