Show alert on click of "approve" action in employee center approvals

mr18
Tera Guru
Tera Guru

How can I show alert on click of "approve" action in employee center approvals under My task

13 REPLIES 13

Community Alums
Not applicable

Hi @Amit Gujarathi , how do you apply the Client script since all of this are in ESC portal's widget?

Hello @Amit Gujarathi 

Thanks for the reply but the thing I am looking for is on employee center.

The solution is similar to what @Community Alums has provided but additionally I want to show the alert while approving some specific catalog item only

Community Alums
Not applicable

Hi @mr18 ,

 

I have done it, it requires quite a lot of steps but will give you the details, I just want to re-test it first

Thank you @Community Alums 

Will wait for your update

Community Alums
Not applicable

Hi @mr18 , please try below if it works your case, I tested it.

During implementation, you may need to switch between Employee Center and Employee Center Core applications.

Also you can name these cloned widgets of your choice, just make sure to reference it correctly in another widgets.

 

Application: Employee Center

  1. Clone "action-widget" widget (https://[instance-name].service-now.com/nav_to.do?uri=sp_widget.do?sys_id=38a3a159530201101865ddeeff...😞
    • ID field is "action-widget-copy"
    • -> Save
  2. Clone "task-configuration" widget (https://[instance-name].service-now.com/nav_to.do?uri=sp_widget.do?sys_id=b96b4449535301105a1eddeeff7b12b4):
    • ID field is "task-configuration-copy"
    • Server script: line 67 -> replace "action-widget" with "action-widget-copy"
    • -> Save
  3. Inside "action-widget-copy" (cloned in Step 1):
    • Client Controller:
      • line 18: recordNumber: $scope.data.actionButtons[0].clientParams.number.value

      • line 20: c.executeClientScript(action, resp.data.actionOutput, resp.data.showAlert);

 

pic 1.PNG

  • line 45: c.executeClientScript = function(action, serverScriptOutput, showAlert) {
  • line 47: if (showAlert == true) {alert('Confirmation box')}

pic 2.PNG

  • Server script:
    • Line 34:

 

if (input && input.hasOwnProperty('recordNumber')) {
        if (input.recordNumber.startsWith('RITM')) {
            var grRITM = new GlideRecord('sc_req_item');
            grRITM.addQuery('number', input.recordNumber);
            grRITM.query();
            if (grRITM.next()) {
                if (grRITM.cat_item == '039c516237b1300054b6a3549dbe5dfc') {
                    data.showAlert = true;
                }
            }
        }
    }

 

pic 3.PNG

 

Application: Employee Center Core