How to disable Approve/Reject in List choice?

priyanka154
Mega Expert

Hi,

In change Request there is a Approver Related list,

When one of the approver approves the request, then In the drop down, it should disable the Approve/Reject choices

How this can be done?

1)

find_real_file.png

2)

find_real_file.png

Thanks,

Priyanka

20 REPLIES 20

Abhinay Thanks for the response,



Can you please share the code which is working for you for form button, I will try from my side and try my luck.




Thanks,


Priyanka


Try modifying for the UI Action where List action is set to true


Hi Padmini ,


Thanks for the response,


When I tried like that, In the list choice drop down, Its showing as Approve(4 of 5).


The requirement is one of the record is approved, it should get totally disable even other approval records are in other states(requeste,no loner required etc) to that specific change request.



Thanks,


Priyanka


Hi priyanka,



  Sorry I was not awake to reply you back. Here is a solution, this will still show the approve button in the list choice but, if the approvals are already approved, even when you click this UI action, it does not update anything. I think this should be helpful. Here is the UI action script and script include for that.



UI action Script:


function getCheckedApprovals(){


  var id=g_list.getChecked().split(',');


  var ga = new GlideAjax('CheckApprovals');


  ga.addParam('sysparm_name','validateApproval');


  ga.addParam('sysparm_ids',id.join());


  ga.getXML(callBack);


  function callBack(response){


  var answer = response.responseXML.documentElement.getAttribute("answer");


  if(answer=="true"){


  g_form.save();


  }


  else{


  return false;


  }


  }


}



Script Include:


var CheckApprovals = Class.create();


CheckApprovals.prototype = Object.extendsObject(AbstractAjaxProcessor, {


  validateApproval: function(){


  var gr= new GlideRecord("sysapproval_approver");


  gr.addQuery('sys_id','IN',this.getParameter('sysparm_ids'));


  gr.query();


  if(gr.next()){


  var gr1= new GlideRecord("sysapproval_approver");


  gr1.addQuery('sysapproval',gr.getValue('sysapproval'));


  gr1.addQuery('state','approved');


  gr1.query();


  if(!gr1.hasNext()){


  var gr2= new GlideRecord("sysapproval_approver");


  gr2.addQuery('sys_id','IN',this.getParameter('sysparm_ids'));


  gr2.query();


  while(gr2.next()){


  gr2.state='approved';


  gr2.update();


  }


  return true;


  }


  return false;


  }


  return false;



  },


  type: 'CheckApprovals'


});



find_real_file.png


find_real_file.png


find_real_file.png


Let me know if this helped??