The Zurich release has arrived! Interested in new features and functionalities? Click here for more

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.
11 REPLIES 11

palanikumar
Giga Sage

Hope this is not client side UI Action. Can you give the full script. How are you calling this function?

Thank you,
Palani

Hi Palani, this is not client side ui action, requirement is to update the state field when the button is clicked on, there is different state field for each view, so using the ui action button wanted to validate the state fields and update for each view as there are different fields which required to be sent for approval. maybe am not going with right approach for the requirement please suggest best possible approach to achieve the requirement.

Ankur Bawiskar
Tera Patron
Tera Patron

@Prasad49 

what's your business requirement?

share the UI action config screenshots.

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 Bawiskar ,

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.

thanks and regards,

prasad.