
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 01:34 PM
So I created a Data Resource to update some records. My issue is that on the page I created I used a "Card Base Actions" component for the buttons. There are 4 buttons. I need to understand two things.
1 - How do I bind data that is in the event to the Data resource so I know what button was clicked. If I use a Client Script the info I need is located at "event.payload.action.label". I need to understand how to use the data binding to get at that information when I bind the Data Resource to the component.
2 - How to call by Data Resource from a client script. On the data resource I set the "Mutates server data" to true. So I thought I could just do the below in a Client Script to call the Data resource but it does not appear to work.
api.data.set_question_answer.execute({
"sectionInstance": section,
"questionInstance": question,
"questionValue": event.payload.action.label,
"comment": ""
});
Any thoughts/help/info would be appreciated.
Solved! Go to Solution.
- Labels:
-
Now Experience UI Framework

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 09:41 AM
Thank you @Brad Tilton for the help. I managed to figure out what I was missing.
1 - To get at the event information using a Data Resource you add the Execute event and then in the upper right you change the "Mode" selection to script and that allows you to use a script to set the values which in turn allows you to use something like "event.payload.action.label".
2 - The reason the Data Resource did not work was because I forgot to create an ACL. Ug, there needs to be a better way to deal with this one, like add it automatically or something. At a minimum you should get an access denied error back when you try and use it. So hopefully lesson learned on that one.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 03:04 PM - edited 09-23-2024 03:06 PM
For your first question, you pass values into a mutate data resource when you call it. Either through a script or its event handler.
That script looks directionally correct. Are your section and answer variables in a format that your data resource is expecting?
The fourth exercise in my CreatorCon lab from this year involves passing data to a mutate data resource if that helps at all: https://servicenownextexperience.github.io/labs/CCL1199-K24-Killer-SAP/overview

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 07:16 AM
The Client Script does show the data I expect but in the Data Broker Server Script I put in a log statement to see what it was receiving and that log statement does not show up in the log so I was assuming it was not being called. But maybe there is another error I need to be hunting for.
What format/syntax should I use to bind "event.payload.action.label" to the questionValue for an event handler? I tried just using "event.payload.action.label" but the interface just removes it.
I did check out the lab, wondering if I have this right. Do I need to add an event handler to set a client state value and then use a second event handler that calls the Data Resource? If so are event handlers always called in the order that they are displayed in UI Builder?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 09:41 AM
Thank you @Brad Tilton for the help. I managed to figure out what I was missing.
1 - To get at the event information using a Data Resource you add the Execute event and then in the upper right you change the "Mode" selection to script and that allows you to use a script to set the values which in turn allows you to use something like "event.payload.action.label".
2 - The reason the Data Resource did not work was because I forgot to create an ACL. Ug, there needs to be a better way to deal with this one, like add it automatically or something. At a minimum you should get an access denied error back when you try and use it. So hopefully lesson learned on that one.