Pop-up confirmation upon approval

VS_09
Tera Contributor

When the approver goes to approval table to approve the request.

Once the approver clicks on Approve UI action button, he should receive a confirmation box saying ' Do you want to approve the request or you still want to continue reviewing? '

If approver click on OK, then request should be approved else it should be untouched (same as before).

 

kaur_developer_0-1708806673616.png

 

If anyone can help. It would be highly appreciated!!

8 REPLIES 8

James Chun
Kilo Patron

Hi @VS_09,

 

You would need to customize the 'Approve' UI Action such that it runs both client-side and server-side codes.

 

Refer to this article for details - https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1005843

 

For your UI Action, it will be something like below (Note that your 'Approve' UI Action will be different to the example below)

 

Action name: approve_record

Client checkbox: true

Onclick: promptApprover();

Script:

function promptApprover() {
    if (confirm("Do you want to approve the request?")) {
        gsftSubmit(null, g_form.getFormElement(), 'approve_record');
    } else {
        return;
    }
}

if (typeof window == 'undefined')
    updateApprovalRecord();

function updateApprovalRecord() {
    //Copy and paste your UI Action's server script
}

Hope it helps, cheers.

 

VS_09
Tera Contributor

@James Chun 

 

That's correct!! But it will impact all the 'Approve' UI Actions for all tables Incident, RITM, Change.

My requirement is to work only for Change request.

 

If anyone can reply...It would be highly helpful!!

You can either create another UI Action that is displayed only on a Change approval or modify the above script to prompt the message only on Change approval.

Either way, note that this will only work with that particular UI Action. i.e. Approval from portal, mobile, etc will not behave the same.

VS_09
Tera Contributor

@James Chun 

Thanks for the reply.

Below is the error I am getting for my script when I tried to approve the change request.

VS_09_2-1709783755270.png

 

 

VS_09_1-1709783706379.png

 

Can you please have a look?