How to detect Toggle is enabled in UI builder page?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 04:57 AM
Hi All,
I have a settings page created in UI builder, where I have created a toggle button.
I want to detect whether that toggle button is enabled, if its enabled then I want to call a scheduled job.
In the scheduled job we have a condition field, but How to check if the toggle is enabled in the ui builder page?
Thanks,
Ajay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 02:18 PM
So when you have a toggle component, and you click on it, the event that is triggered is going to look something like :
{
"elementId": "toggle_1",
"name": "NOW_TOGGLE#CHECKED_SET",
"payload": {
"value": false
},
"context": {},
"eventInfo": {
"sourceElementId": "cm257v4cm0001359c4kaprjng"
}
}
Where the event.payload.value will be false or true depending if it is not toggled or toggled respectively.
So what you can do is set a client state variable, to true or false depending on that event.payload.value.
Then you can create a data source type of transform with 1 input parameter, to which you are going to map your client state created above (the resource should be invoked each time the client state changes)
Then in your data broker, you can just run server side code, so you can trigger whatever code you want from there, just make sure to check other broker examples so you know how to add the properties required for the input to be passed.
Hope it helps.
Cheers