1

I've created a parent list (Vendors) and a child list (software list). There can be multiple vendors for one piece of software. I've created a custom new form with a link which opens up a modal to add a new vendor while filling out the Software form. I need it to save the vendor to the vendors list and then refresh the software form when the modal closes, but retain all the values they've already entered.

Seems like it should be a common request, and I've read several posts and suggestions on the subject already. I've gotten it to work with just a single lookup drop down...the problem comes when I switch it to a multiple lookup. It adds the item to the list, but then does not refresh the list on the form. There have been a couple of posts on technet about it:

http://social.technet.microsoft.com/Forums/sharepoint/en-US/ee4755c5-3d7c-4772-983f-3d9e8b7151ea/modal-dialog-box-multiplelookupfield-on-newformeditform-is-not-refreshing?forum=sharepointgeneralprevious

http://social.technet.microsoft.com/Forums/en-US/a38cbc86-96c9-4bd3-869f-16207533c0a1/spuimodaldialog-methods-refresh-parent-issue?forum=sharepointgeneralprevious

but neither of these end with a proper resolution. Anyways, here's the code I have currently:

<a href="#" onclick="OpenVendor('/sites/ITSite/Lists/Vendors/NewForm.aspx');">Add new vendor</a>

And the javascript:

function OpenVendor(listUrl) {
    var options = {
        url: listUrl,
        dialogReturnValueCallback: scallback
    };
    SP.UI.ModalDialog.showModalDialog(options);
}

function scallback(dialogResult, returnValue) {
    if (dialogResult == SP.UI.DialogResult.OK) {
        SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
    }

I've tried options.dialogReturnValueCallback = RefreshOnDialogClose with the same results. The only thing that seems to work so far is location.reload(true) but that refreshes the entire form and throws out all the entered fields.

I need to stick with javascript and can't load any outside add-ons in. JQuery is fine. Thanks in advance for any and all help.

1 Answer 1

1

Assuming this is SharePoint 2010 (looks like it), there's an easier way to do it.

Try this instead:

<a href="#" onClick="javascript:OpenPopUpPage('/sites/ITSite/Lists/Vendors/NewForm.aspx?IsDlg=1', RefreshPage)">New Vendor</a>

What this will do is open your New Item form in a modal dialog, then refresh the parent page when that dialog closes. The IsDlg=1 on the end will keep the dialog trimmed & neat-looking.

I haven't tried this with an InfoPath form, but it works with the default SharePoint forms.

4
  • Unfortunately that yields the same results as the other code - the modal pops up, the new vendor is saved, the page refreshes...keeping all the filled in data, but the new item doesn't get added to the Multi-select field. It works fine with a single lookup. I'm currently writing some javascript to force the updates, but if there is an easier way, that'd be great. So far I've still been unable to find anything.
    – Djuwal
    Commented Feb 14, 2014 at 15:28
  • Strange - we're currently using that method on several list forms and it seems to work correctly. I wonder if it's an issue with the lookup column itself maybe?
    – Omegacron
    Commented Feb 14, 2014 at 17:06
  • Are you running 2010 sp2? We are on 2010 sp1...maybe it's a glitch with that? I've tried to create several other multi lookups and all come out with the same result. Again, works fine on single lookups. And we are actually looking to upgrade to 2013 and bypass the sp2 update on our farm. Can anyone verify if the OpenPopUpPage works for multi lookups on 2013 when set to refresh?
    – Djuwal
    Commented Feb 14, 2014 at 17:16
  • A more complex option would be to convert the form to an InfoPath form, then add a button that uses rules to refresh the datasource behind the field. That way the refresh would affect only the lookup values and not the rest of the form. You'd still need a separate link to open the modal dialog, though, so it would also add a separate step for the users (add the vendor, then refresh the list by clicking the button).
    – Omegacron
    Commented Feb 14, 2014 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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