Tech Support > Microsoft Windows > Windows CRM > "OnClose" event on a form? (crm 3.0)
"OnClose" event on a form? (crm 3.0)
Posted by Nicolas Pagès on May 15th, 2008


Hi,

Is there any way to have access to the onclose event of a form? I would
like some code to be executed even when the user does not save any change,
but it has to happen on the close event, not on the load event.

Thanks!

--
Nicolas Pagès

Posted by Richard Riddle on May 15th, 2008


There are a couple different ways to do this, whether they are supported is
unclear. in the onload script of your window, put in something like

window.onunload = function()
{
alert("the window is closing now");
}

This attaches the alert code to the window unload event and you should the
alert when you close the window, regardless of how it's closed or if any data
has changed. This could be defined as unsupported because if Microsoft ever
put their own code in the onunload event of the window object, the above code
would over write it and cause unexpected behavior.

--
Richard Riddle
CRM Developer
Autonomix


"Nicolas Pagès" wrote:

Posted by Nicolas Pagès on May 15th, 2008


Hi Richard,

Thanks you. You're right, it's probably unsupported since it's not
mentionned in the crm doc anyway. Plus, I tried the window.onbeforeunload
event and it did overwrite the Microsoft alert warning that changes will be
lost. Still, this is the only way I could think of to capture the event of a
campaign becoming a related campaign. This is because you can add a related
campaign to campaign A, and then close campaign A without having to save it.
Besides putting a trigger on the campaignitem table of course...

Anyway, if you can ever think of a better solution, please let me know.

Thanks again!

Nicolas Pagès


"Richard Riddle" wrote: