2

I have some code I want to run on a list item after any properties (metadata) are saved from the editform window. Where/how can I put JavaScript to run at that time? Thanks!

1 Answer 1

5

I figured it out! You need to use dialogReturnValueCallback which executes a function after the EditForm window closes.

Go here for details on answer: SharePoint Modal Help - pass value back to parent when closing

Here is the appropriate code from that link:

//you create the Modal dialog like so...

//Dialog Opening
function OpenDialog() {
    var options = SP.UI.$create_DialogOptions();
    options.url = '/_layouts/mySolution/myPage.aspx';
    options.width = 500;
    options.height = 400;
    options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
    SP.UI.ModalDialog.showModalDialog(options);
}

//and then make the return function like this...

// Dialog callback
function CloseCallback(result, target) {
    if (result == SP.UI.DialogResult.OK) {
        // Run OK Code
        // To be consistent with the below... 
        this.dataArray = target.split("^");
        var startDate = new Date(this.dataArray[1]);
        // Note that I use this.dataArray to allow the object to be accessed throughout the code
    }
    if (result == SP.UI.DialogResult.cancel) {
        // Run Cancel Code
    }
}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.