Page 1 of 1

Execute Javascript on Parent Form when Child form closes

Posted: 06 Jul 2017
by charles267
Hi there,

For a related item list, we are closing the child form using "SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Cancel)" which closes the child form. We would, however, like to execute some javascript on the parent form after this child form closes. Any idea how this can be done? Thanks!

-Charles

Re: Execute Javascript on Parent Form when Child form closes

Posted: 06 Jul 2017
by Nikita Kurguzov
Hello, Charles!
Yes, there is a way to do it. Use JavaScript editor from the New Form of Child element and code similar to this:

Code: Select all

ExecuteOrDelayUntilScriptLoaded(function() { 
     
     //Here you can access all the elements from the Parent Form with this code:
    window.top.fd.field("Name of Your field")...
    
    //And this will close the dialog box after executing the code
    SP.UI.ModalDialog.commonModalDialogClose(0); 
     
}, "sp.ui.dialog.js");

Re: Execute Javascript on Parent Form when Child form closes

Posted: 06 Jul 2017
by charles267
Thanks so much! Will let you know how it goes.