UI Builder: show other component if in the repeater there is an empty array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2022 11:28 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2022 03:32 AM
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.
4. Set same property on your stylized text component as !@state.hideRepeater.
Hope this helps.
ServiceNow Community Rising Star 2022/2023