UI Builder: Staggered Loading of Data

Hasan6
ServiceNow Employee
ServiceNow Employee

Hi Community,

I am creating a UI Builder page.

Here I have a dynamic number of data points on the server/instance, which I want to show on the page.

But as the processing time for each data point is high, I want to load the data on the page one after the other as and when the server-side script finishes executing that section of code.

 

The algorithm for the server side script should be as such:

 

for(var i=0; i<dynamic_number; i++){

    var data = getData(i);

    pushToClient(data);

}

 

How do I configure this in the UI Builder?

As the number of data points is dynamic, I suppose I will need only one data broker to get all the data.

But how do I get data in this staggered way?

 

Thanks in advance

2 REPLIES 2

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Every data resource has a success event it fires so you could just chain the data resources together, but for a dynamic amount of data that may be difficult. One of the issues would be that if you reuse the same data source it's outputs will change every time you call it so you won't be able to directly map the data to components, you'd need hold it all in client state parameters. You'll also need some CSP to handle incrementing. 

Nootan Bhat
Kilo Sage

Hi @Hasan6,

The data sources have the control to invoke them. You can immediately invoke or else you can use the Explicit.

You can invoke your first data source Immediately and after the success you can use the Success even to invoke next data source (which is set as Explicit). Or else you can call the client script after success of one data source and related code/data changes you can use the api.emit to call the next event or data source execution event.

in this way you can store the previous fetch results in next fetch and find the related data.

 

Please mark my solution as accepted if it helped.

 

Thanks

Nootan