UI Builder refresh related list inside modal

Casper6060
Mega Sage

I have create an acction assigment that runs from the related list pointing into the incident table.

This button is implement as a UXF Client Action.

When i click the button, a modal opens up with my UI Builder page inside.

One of the buttons on the page adds a child incident to the incident of the current page i am on.

 

This works perfectly, the issue is that the related list does not update.

 

I checked the existing refresh button and also the remove button, both of which reload the related list after clicking.

 

In the next experience profiler i see 2 actions i can dispatch which can do the job.

REFRESH_REQUESTED

NOW_RECORD_UI_ACTION_BAR#REFRESH_REQUESTED

 

But when i try to call any of these actions from my UI Builder page, they dont work, i'm guessing this is because it's in a different scope so to say?

 

Is there any way to achieve what i'm looking for?

1 ACCEPTED SOLUTION

Casper6060
Mega Sage

Finally i found an acceptable workaround. I tried ALOT of different things like emitting the "RECORD#RELATED_LIST_REFRESH_REQUESTED" event (which does emit, but from what i can tell, it cant reach the related list behind the modal, so nothing happens because the event is fired from the wrong macrocomponent).

But instead if we use the event GFORM#RELOAD it works by reloading the entire form, both the modal but also the form behind the modal, but if we put this event just after helpers.modal.close, it only feels like the actual form is being reloaded. Granted, its not 100% ideal since the perfect scenario would be to ONLY reload the related list part of the form and not the entire form, but this is acceptable.

To make this work i opened my UI Builders page definition, and scrolled down to the bottom and added the "Reload a form" event in the Dispatched Events section, this is needed, otherwise ui builder ignores the event being fired (this is stated in the ServiceNow documentation).

Casper6060_0-1725803684561.png

 

After i saved the page definition, i reloaded UI Builder and confirmed the event appeared under dispatched events

Casper6060_1-1725803730732.png

Finally i can call the event from my client script

Casper6060_2-1725803766212.png

 

Of course you could also call the event on button click or data retrieved successfully, but in my real world scenario (images where from a PDI test page i setup) i needed the script setup to fire the event.

 

Thanks a lot for everyone's help, if someone else finds a better solution, do please let me know

View solution in original post

2 REPLIES 2

Serghei Tolstov
Tera Contributor

i may not understand the setup and the issue fully, but it looks to me that nothing triggers window refresh from the modal, i assume there should be an action button (ex Confirm)  which can trigger form refresh through UI action scripting   (location.reload() or g_list.refrash() or reloadWindow(window) )  or event (from ui builder)


here is an example of a Action to Event mapping  https://www.youtube.com/watch?v=lTDa8nFRvmU 
(this is for a List view but i think it is similar logic could be applied for Related List Action
)

 
 
 

Casper6060
Mega Sage

Finally i found an acceptable workaround. I tried ALOT of different things like emitting the "RECORD#RELATED_LIST_REFRESH_REQUESTED" event (which does emit, but from what i can tell, it cant reach the related list behind the modal, so nothing happens because the event is fired from the wrong macrocomponent).

But instead if we use the event GFORM#RELOAD it works by reloading the entire form, both the modal but also the form behind the modal, but if we put this event just after helpers.modal.close, it only feels like the actual form is being reloaded. Granted, its not 100% ideal since the perfect scenario would be to ONLY reload the related list part of the form and not the entire form, but this is acceptable.

To make this work i opened my UI Builders page definition, and scrolled down to the bottom and added the "Reload a form" event in the Dispatched Events section, this is needed, otherwise ui builder ignores the event being fired (this is stated in the ServiceNow documentation).

Casper6060_0-1725803684561.png

 

After i saved the page definition, i reloaded UI Builder and confirmed the event appeared under dispatched events

Casper6060_1-1725803730732.png

Finally i can call the event from my client script

Casper6060_2-1725803766212.png

 

Of course you could also call the event on button click or data retrieved successfully, but in my real world scenario (images where from a PDI test page i setup) i needed the script setup to fire the event.

 

Thanks a lot for everyone's help, if someone else finds a better solution, do please let me know