I've a requirement to subscribe a function on close and open of a document(Harness) for a mulit-document container across the application.
I achieved for modal dialogs by using below code.
Scenario: My work area(multi-document container) has a list of work items. From those, I'm opening a work object, where the assignment's flowaction has "IF AN ASSIGNMENT IS NOT BEING PERFORMED" is configured as Close the work object and also has a custom button to FINISH ASSIGNMENT(inside the flowaction section). So, once after clicking on the button it closes the document and falls back on to the work area, while fallback I want to subscribe a function which calls a custom function (likewise for modal dailog).