How to run a custom script after the default refresh() method has finished

I’ve written a custom script to modify the UI of a doctype (support ticket) to make it more appropriate for our scenario (we need interleaved comments and communications).

The script works fine in isolation (it gets comments and communications, sorts them appropriately, populates a different panel).

However, it needs to run only after the default UI has been fully rendered. cscript.custom_refresh doesn’t seem to work - within the default refresh() I believe there are still ajax queries pending to fetch the support tickets from the server, at the time custom_refresh runs.

My question boils down to: how do I run a custom script after the default refresh() method has finished fetching things?

Many thanks.

Try this trigger:

cur_frm.cscript.custom_onload_post_render