How to show the message when approver click on approve when request come specific catalog item

Brahmi Pandla
Tera Guru

Hi Everyone,

 

I have a requirement for to show the message when approver click on approve button

 

1. approval send  to group manager after group manager approved another approval send to business owner 

i done this 

now i want show the message  “have you transferred all active tickets, tasks, and applications?” Yes approved when both approvers click on approve button

 

how can i achieve this

I am trying through  Display BR  sysapproval_approver  table  but how can i get the cat item

 

 

 

1 ACCEPTED SOLUTION

Hi Ankur,

 

The below code will effect on all catalog items

Display BR

 

(function executeRule(current, previous /*null when async*/) {

    var ritmSysId = current.sysapproval;
    var gr = new GlideRecord("sc_req_item");
    gr.addQuery("cat_item.name", 'Add/Modify Servicenow Assignment Groups');
    gr.query();
    g_scratchpad.showMessage = gr.hasNext().toString();

})(current, previous);
 
Onload client script
function onLoad() {
   
    if (g_scratchpad.showMessage == 'true') {
        g_form.addInfoMessage('have you transferred all active tickets, tasks, and applications? Yes approved. No do not proceed (but DO NOT reject)');
    }


}

View solution in original post

9 REPLIES 9

@Brahmi Pandla 

you will have to update OOB Approve button which I won't recommend

what's the issue if they see the message when State is Requested?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Brahmi Pandla 

if you want to update the OOB Approve UI action then do this

1) Search for OOB Approve button which is form button on sysapproval_approver table

2) Make it Client checkbox = true

3) Onclick field - showMessage()

4) Script:

function showMessage() {
    var ritm = new GlideRecord('sc_req_item');
    ritm.addQuery('sys_id', g_form.getValue('document_id'));
    ritm.addQuery('cat_item.name', 'Your Catalog Item Name Here');
    ritm.query();
    if (ritm.hasNext()) {
        var confirmMessage = confirm("have you transferred all active tickets, tasks, and applications?");
        if (confirmMessage)
            gsftSubmit(null, g_form.getFormElement(), "approve");
    } else {
        gsftSubmit(null, g_form.getFormElement(), "approve");
    }
}

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

function markApproved() {
    current.state = 'approved';
    current.update();
    new ApprovalUserFeedback().approved(current);
}

AnkurBawiskar_0-1735291497838.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Brahmi Pandla 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

The below code will effect on all catalog items

Display BR

 

(function executeRule(current, previous /*null when async*/) {

    var ritmSysId = current.sysapproval;
    var gr = new GlideRecord("sc_req_item");
    gr.addQuery("cat_item.name", 'Add/Modify Servicenow Assignment Groups');
    gr.query();
    g_scratchpad.showMessage = gr.hasNext().toString();

})(current, previous);
 
Onload client script
function onLoad() {
   
    if (g_scratchpad.showMessage == 'true') {
        g_form.addInfoMessage('have you transferred all active tickets, tasks, and applications? Yes approved. No do not proceed (but DO NOT reject)');
    }


}

@Brahmi Pandla 

No

you are querying only for particular catalog item so it will work only when approval is raised for RITM belonging to that particular catalog item only

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader