Close report preview window from x++

This question has suggested answer(s)

Just wondering is there anyway to close all report preview windows from x++

All Replies
  • I don't have a solution for you, but maybe some ideas will bear fruit.

    If one of the client caches maintained a list of all open forms, you could loop through them, decide if each should be closed (form name?), and then do a formRun.close() as needed.  

    If you wanted to build your own such cache, you could override info.formNotify() and maintain a reference to each newly opened form in your own cache (remember to remove them on form close or they won't destruct properly).  Class\smmPhoneIntegration does roughly the same thing for tracking open forms with phone integration so that it can deliver inbound TAPI events to them (except that it's only doing this for forms it opens).  It uses Class\smmObjectList to track forms in a linked list arrangement.

    I though about using WinAPI::findWindow(..) to locate open windows by title, but you would have to know the name of the report title.  A similar approach might loop through all child windows of the AX process and make a decision about each window.  This seems like more of a hack.

    Maybe someone else knows how to loop through all open forms in X++.  That would be the cleanest approach.

    Good luck!