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

Ankur Bawiskar
Tera Patron
Tera Patron

@Brahmi Pandla 

you can query and get the catalog item name

Use Before Update BR and condition as State [Changes to] Approved

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

    // Add your code here
    var ritmSysId = current.sysapproval;
    var gr = new GlideRecord("sc_req_item");
    gr.addQuery("cat_item.name", "Your Catalog Item Name Here");
    gr.query();
    if (gr.next()) {
        gs.addInfoMessage('have you transferred all active tickets, tasks, and applications?');
    }

})(current, previous);

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Brahmi Pandla 

you can use onload client script on sysapproval_approver table + Display BR

Something like this in Display BR

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

    // Add your code here
    var ritmSysId = current.sysapproval;
    var gr = new GlideRecord("sc_req_item");
    gr.addQuery("cat_item.name", "Your Catalog Item Name Here");
    gr.query();
    g_scratchpad.showMessage = gr.hasNext().toString();

})(current, previous);

onLoad client script on sysapproval_approver

function onLoad() {

    if (g_scratchpad.showMessage == 'true')
        g_form.addInfoMessage('have you transferred all active tickets, tasks, and applications?');

}

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,

Thanks for response

Message is showing when state is requested .

 but my requirement is  when approver click on approve button message  should appear state should not be change

 

BrahmiPandla_0-1735286292982.pngBrahmiPandla_1-1735286316693.png