- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 07:19 AM
I have created a custom component and I want to trigger an event in that component from the UI Builder. Is it possible to call that event? I tried api.emit('EVENT') in a client script but that didn't work.
Otherwise I would have to watch a property? But not sure if that's even possible?
Solved! Go to Solution.
- Labels:
-
Now Experience UI Framework

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2022 05:46 AM
Ahh so components are built as properties in and events out, so I would expose a property that you want to monitor and then use your event in UIB to change a CSP you've bound to that property in UIB.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2022 05:21 AM
Hi Philippe,
THere are a couple of extra steps you need to take when deploying the component to the instance in order to make it fire an event you can consume from UI Builder. I've got a blog and video on the subject here: https://developer.servicenow.com/blog.do?p=/post/quebec-ui-builder-custom-component-events/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2022 05:42 AM
Hi Brad,
Thanks again for answering! I've done these steps. But what I want to achieve is "the other way around". So emit an event from a script in the UI builder that then triggers an action in my custom component.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2022 05:46 AM
Ahh so components are built as properties in and events out, so I would expose a property that you want to monitor and then use your event in UIB to change a CSP you've bound to that property in UIB.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2022 05:51 AM
That makes sense. But how can you monitor a property? In vue there are watchers https://vuejs.org/v2/guide/computed.html#Watchers but couldn't find something similar for Now UI?
To clarify: what I try to accomplish is drawing markers on a map. For this I need to call a certain API, I can not implement this reactively...