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.

Which UIB component to use to display a JSON array?

mtrojahn
Tera Contributor

I am retrieving some data from a REST API by using a Flow, triggered by a server script, and then used on a transform data resource. This leaves me with a JSON array of objects which I want to bind to a "datatables"-like component.

Is there such a component? I tried to use a List Simple component but with no luck. The only way I was able to show the data was by using a Repeater and using Labels, but that is far from ideal.

This is an example of data that I wish to bind to a "table".

find_real_file.png

Thanks in advance.

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Yeah the problem with the current iteration of the list components is that they're probably the format you want, but they can only pull from SN tables so you'd need to pull that data into a table somewhere and reference that table from the list component.

If you can't do that, then your options are basically:

  • Using a repeater (or nested repeaters). You could also use a scriptlet data resource to manipulate the output of the data so it's easier to use in a repeater (like repeating over both labels and values so you're not hardcoding labels on the page).
  • Use the data row or data set components, but they do need a very specific JSON format in order to display correctly.

Yeah, sad to hear that.

That was the conclusion I was getting to. I'd really like to use something like a List Simple to take advantage of the built-in features like filters, sorting, etc.

Maybe I can import an external JS library (like datatables) to use on my UI? That would actually be a nice option if I can, somehow, trigger actions when I interact with the data in it.

Hi @Brad Tilton 

We really need this capability in multiple areas in our business. Any chance this feature gets developed for UI Builder going forward?

The newest version of the list component, presentational list, does decouple the data handling into a controller that then binds the data to the component. (It no longer directly handles its own data). Because of that it is technically possible to take your own data that is not necessarily tied to a table and bind it to the component. That being said, there isn't much enablement out there for this edge case so you'd need to figure out the format of the data it's expecting and provide it that format. NED Tools may help there.