Can't figure out how to pass the text from a dialog box into the sysapproval comments box?

evaoconnell
Giga Contributor

Hi there

In order to Reject Approval from a Context Menu,   I have created a ui action which then calls a ui page (with client script included) and displays a dialog box,   however when I click 'Ok' on the dialog box I'd like the text that was entered into the dialog box to copy into the comments box in the approval form.   Can't figure out how to do this?   Ideas welcome 🙂

1 ACCEPTED SOLUTION

UI action script: (Just add the line in bold)


function popupRejectApproval() {


  var gdw = new GlideDialogWindow('reject_request');


  gdw.setTitle('Reject this Request');


  gdw.setPreference("selectedRecord",rowSysId);


  gdw.render();


}



UI page client script:


function validateComments() {


  var selectedRecord = "${RP.getWindowProperties().get('selectedRecord')}";


  var dialcoms = gel("dialog_comments").value;


  var comments = trim(dialcoms);


  if (comments == "") {


  alert("Comments are mandatory for rejection");


  return false;


  }


  var getApproverRecord = new GlideRecord('sysapproval_approver');


  if(getApproverRecord.get(selectedRecord))


  {


  getApproverRecord.comments=comments;


  getApproverRecord.state='rejected';


  getApproverRecord.update();


  }


  GlideDialogWindow.get().destroy(); //Close the dialog window



}



Note: Change the querying part to a glideajax. Once the record is updated, redirect to the record you want else the screen will appear as static making you believe that the update has not happened.


View solution in original post

35 REPLIES 35

Hi again



I haven't been able to figure out how to stop the Business Rule conflicting with the UI Page update it's the getApproverRecord.update();   bit that conflicts.   Gives me an error of :



Error Message.png


Do you have any suggestions around this?



Many thanks


I need to check the code of that business rule and it looks out of the box to me from its name.

Yes it's definitely out of the box which is why I need to change the UI Page rather than the BR I guess!


I will need your help to debug this.



Can you check the approval record before rejecting and what value this column has 'source_table' ?



If possible, a screenshot would help.


Thanks



See screen shot below:       Is this what you need?




Source_Table.png