UI Builder: show other component if in the repeater there is an empty array

Fabrizio Joaqui
Mega Guru

Hi, I'm building a page in UI Builder using some repeater components. The repeaters have a nested container which in turn have 3 Stylised Text Components pulling dynamic data using @item... from a dynamic data source bound to the repeater.

 I would like that if in the data source of the repeater there is an empty array, the child container that contains the stylized texts shows me a text with written "No Records here", how can I do?

1 REPLY 1

JagjeetSingh
Kilo Sage
Kilo Sage

Hi,

 

1. Create a state parameter of type boolean on your page. e.g. hideRepeater.

2. Once your data source complete it's execution, trigger a client script and set the state parameter. If the data is empty set it to true, else set it to false.

api.setState("hideRepeater", true); //Set to true if empty

3. On your repeater component bind the state parameter to hide component property.

JagjeetSingh3_0-1670153502202.png

 

4. Set same property on your stylized text component as !@state.hideRepeater.

 

Hope this helps.

 

 

 

 

 

 

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023