How to add dynamic action buttons in a List based on record field values?

sabra_gr
Tera Contributor

I’m working on a UI Builder page where I need to display a list of records. One of the columns in the list should include dynamic action buttons, where the label and functionality of the buttons depend on the value of a specific field in each record.

My Requirements:

  • The list displays records fetched from a table.
  • In the "Actions" column:
    • The button label and functionality should change dynamically based on the value of a field in the record: 
    •  if State field is "Open" display a button labeled "Start"
    •  if State field is "In progress" display a button labeled "Resume"

My Questions:

  1. Is it possible to implement dynamic buttons in the List by adding a UI Action List field? If yes, how can I configure it in UI Builder?
  2. If a UI Action List field is not suitable, what other declarative options are available in UI Builder to achieve this functionality?

Thank you for your guidance and insights!

1 ACCEPTED SOLUTION

@sabra_gr ,

 

according to this old post, users are unable to add buttons to individual rows.

 

https://www.servicenow.com/community/developer-forum/creating-buttons-on-each-row-of-a-list/m-p/1476...

 

BUT

 

you can add custom button component above or below LIST component and make it dynamic upon users clicking on individual row. You can access payload of selected row and react on that payload dynamically. So even a button Label can be dynamic depending on row clicked to show actual action type that is going to happen.

View solution in original post

6 REPLIES 6

IronPotato
Mega Sage

Hi @sabra_gr ,

 

is the button for individual row a must?

Hi @IronPotato , 

Yes, having the button for individual rows is a must because the action needs to be specific to each record. The button will trigger a unique operation based on the status or data associated with that particular record, making it essential for individual rows to have their own buttons.

@sabra_gr ,

 

according to this old post, users are unable to add buttons to individual rows.

 

https://www.servicenow.com/community/developer-forum/creating-buttons-on-each-row-of-a-list/m-p/1476...

 

BUT

 

you can add custom button component above or below LIST component and make it dynamic upon users clicking on individual row. You can access payload of selected row and react on that payload dynamically. So even a button Label can be dynamic depending on row clicked to show actual action type that is going to happen.

sabra_gr
Tera Contributor

@IronPotato 

Thank you for your input. Since adding dynamic buttons to individual rows in the list isn't possible as per your suggestion, I explored an alternative using the UI Action List Field Type.

I followed this article: Using UI Action List Field Type, and with it, I was able to:

  1. Add a new column to my table using the UI Action List Field Type.
  2. In the standard table list view (outside of UI Builder), this column displays a UI Action as a clickable link for each record (row).

However, when I added the List Component in UI Builder to display this table:

  • The "Actions" column (configured using the UI Action List Field) appears as plain text instead of an interactive link or UI Action.

I’m looking for a way to make the UI Action List Field Type column behave as expected in the UI Builder List Component, where it would function as a record-specific UI Action (similar to its behavior in the standard table list view).

Any suggestions or guidance would be greatly appreciated. Thank you!