Help with UI Builder and Component Event Access to Data Resource

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2024 01:40 PM
Quick background, I'm very new to UI Builder. I'm also new to React and other experience that might fill in my learning gaps. That said, I have a fair amount of conceptual understanding of how it all comes together after using a number of videos, blogs and posts here to assist me in attempting some basic page configuration and customization. We are on Washington release currently.
I was following along with this You and I builder walkthrough and was successful in completing most of the tasks. The base for my page includes a repeater and a cardbase container. Each card handles a single record from my data resource, which is a 'look up multiple records'.
So I have my cards and they do display the fields I've selected. What they do not do is open the record when clicked. My question, how can I dynamically retrieve the table used in my 'look up multiple records' data resource for use in my 'card clicked' event handler? It works when I hard code the table but there has to be a way to dynamically relate this.
Do I need to do some magic to store this in a client state variable or is it possible to obtain it from the data resource?
Happy to provide additional details if needed.
Page setup:
- Lookup multiple records (data)
- Repeater + card base container (components)
- Card clicked (event handler)
- Labels:
-
UI Builder : Next Experience
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2024 05:03 AM - edited ‎11-22-2024 05:05 AM
Hi @User303823 ,
add event to your card clicked event mapping. Create client script for example logEvent and in that script place:
const cardData = api.item.value;
console.log('cardData', cardData);
trigger this client script on that card click event
all the meta data from your DR pointing to that particular card will be available for you.
Hope that helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2024 05:59 AM
You can't directly reference a property on a data resource or component from somewhere else (including a script) in most cases. That means if you hardcode the table name into the data resource property, unless the data resource has the table in its response, you'd have to hard code it in your event handler.
If you have a value that you want to reference from multiple places, in this case the data resource property and then event handler, you can put that piece of data into a client state parameter and reference it from both of those spots.