0

I have a list and a document library (List A and document library B), both opens in dialog.

Document library B has a lookup column targeting list A. On the display form on List A the document webpart from document library B is added (Parent-child relation).

Whenever I drag and drop a file into the document library B webpart, I have a javascript added to the form which ensures the edit/check in form of the document opens in a dialog (on top of the dialog of the item in list A).

Now I need it to auto fill the lookup column with the ID of the item from list A. This works perfectly fine as long as list A does not open in dialog, but i need it to work in dialog as well.

How do I get the ID of the "second dialog" dialog other than the active one?

Edit:

I have tried both window.parent.location and window.top.location both only returns the url from the main page (Eg. list view) which of cause does not contain the ID I'm looking for.

1

Asuming you are working with sharepoint dialogs, the sharepoint dialog has a property called callback in wich you can provide a funtion for executing after the dialog is close, example:

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);
}

function CloseCallback(result, target) {
    if (result == SP.UI.DialogResult.OK) {
        // Run OK Code            
    }
    if (result == SP.UI.DialogResult.cancel) {
        // Run Cancel Code
    }
}

In the OK result you can get the id you need, then store it in some control (hidden text perhaps) then pass it to the new dialog, reading it the control where you store the value.

  • Thanks - that seems a bit over the top having to do that. I mean the parent dialog must be including the ID of the item in the URL (dispform.aspx?ID=XX) even if it's not shown. I thought it would be possible to get the value and from there is rather trivial to extract the ID :) – Morten K Dec 27 '17 at 14:58
  • But thanks for the suggestion anyway :) – Morten K Dec 27 '17 at 14:59
  • no, you can not, you have to pass the value by querystring – Marco Dec 27 '17 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.