List of Event Names for api.emit in UI Builder

nwilliam
Tera Contributor

Is there a list or a way to figure out the name of events for the api.event() method?  I'm specifically looking to trigger the Form Controller event for the activity stream to "Request Email Action - Data Resource" in a client script.  I would like to do it there because I have other bits I'd like run synchronously with it.  I believe I can use api.emit() but although I know the payload I do not know the event name for that or where to find it.

1 ACCEPTED SOLUTION

Kevin83
ServiceNow Employee
ServiceNow Employee

Depending on the release you are on you should be able to see a list of event handlers using a different method.

Rather than using api.emit, you could use api.data.<dataresourceid>.<operation> like so:

Screenshot 2025-01-03 at 10.40.20 AM.png

 and here you can see the payload too:

Screenshot 2025-01-03 at 10.40.28 AM.png

It is generally preferable to use this over api.emit as you are referring to a specific data broker.

View solution in original post

3 REPLIES 3

Kevin83
ServiceNow Employee
ServiceNow Employee

Depending on the release you are on you should be able to see a list of event handlers using a different method.

Rather than using api.emit, you could use api.data.<dataresourceid>.<operation> like so:

Screenshot 2025-01-03 at 10.40.20 AM.png

 and here you can see the payload too:

Screenshot 2025-01-03 at 10.40.28 AM.png

It is generally preferable to use this over api.emit as you are referring to a specific data broker.

Brad Tilton
ServiceNow Employee
ServiceNow Employee

One option for discovering events is to use the Next Experience Dev Tools Chrome extension. It'll let you monitor and surface any events triggered on the page. 

IronPotato
Mega Sage

Hi @nwilliam ,

 

api.emit is only used if you want to trigger dispatched events that are defined on page it self so if you click on Body component you can see your dispatched events. 

 

IronPotato_0-1736439122361.png

I don't think you can trigger Form Controllers events from client scripts but you can reverse the logic and add client script to some event when you change is captured on Form controller, for example "Form status changed" and add your client script there which you need to run async.

 

If my answer helped you in any way, please then mark it as helpful or correct. This will help others finding a solution.