Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

trying to configure same UI action for three different views of the same table

Prasad49
Tera Contributor

Hi experts,

 

i am trying to configure same UI action for three different views of the same table, below is the script that i am trying with but its not working 

(function executeAction(sysIds, table) {
    var gr = new GlideRecord(table);

    for (var i = 0; i < sysIds.length; i++) {
        if (gr.get(sysIds[i])) {

       
            if (gr.u_state_a == 'draft') {
                gr.u_state_a = 'pending_for_approval';
            }
      
            else if (gr.u_state_b == 'draft') {
                gr.u_state_b= 'pending_for_approval';
            }
       
            else if (gr.u_state_c == 'draft') {
                gr.u_state_c = 'pending_for_approval';
            }

            gr.update();
        }
    }
    gs.addInfoMessage("Selected records sent for approval.");

Business Requirement

I have three different list views (View A, View B, and View C) for the same table sn_grc_profile.

Each view shows different fields (X, Y, Z). The process is:

  1. A user fills out the fields in a view (for example, field X in View A).

  2. The user selects records in the list view and clicks Send for Approval.

  3. A reviewer (checker) goes to the same view, reviews the records, and clicks Approve (or Reject) from the list view.

Currently, I created three separate buttons for each action: Send for Approval, Approve, Reject.

My challenge is that I want to reuse the same UI Action button across all three views.

  • Example: one Approve button should work for all three views (instead of having 3 separate Approve buttons).

  • Same goes for Reject and Send for Approval.

Also, the requirement is that users should be able to update multiple records directly from the list view using these buttons.



requesting for support on the issue, thanks in advance.
12 REPLIES 12

Prasad49
Tera Contributor

Hi @Dhana,

 

Thanks for your kind response am trying to use Ui action button to update record which checks the current state of the record in the list view and update it when Ui action button is clicked.

Hi @Prasad49 ,

 

I understand that. But wasn't your question about using same button for all the views?

@Prasad49 

check my above response.

I believe that should 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