Related Items when parent is opened in Dialog
Posted: 09 May 2019
Hi, I've been looking at https://spform.com/related-items/creati ... ms-control
In it, it outlines how to use a standard new form in the related items control to add new items, which works fine when my parent form is opened in a page, however, in some cases the parent form will be opened as a dialog. If this is the case, the code does not seem to populate the lookup field in the 'child' item.
Is there some way I can get this to work when my parent form is a dialog? I considered changing the reference of window.top to window.parent but that seems to make no difference and still fails to populate the lookup field.
Hopefully this makes sense! Please let me know if you need further information. I am using SharePoint 2013 server and Forms Designer 3.1.4.
Thanks
Andy
EDIT - I think I fixed it by adding this into the new form and setting the lookup field with parentId:
var parentId = $('.ms-dlgFrame', window.top.document)[0]
.contentWindow.GetUrlKeyValue('ID');
But please tell me if I'm doing this wrong!
In it, it outlines how to use a standard new form in the related items control to add new items, which works fine when my parent form is opened in a page, however, in some cases the parent form will be opened as a dialog. If this is the case, the code does not seem to populate the lookup field in the 'child' item.
Is there some way I can get this to work when my parent form is a dialog? I considered changing the reference of window.top to window.parent but that seems to make no difference and still fails to populate the lookup field.
Hopefully this makes sense! Please let me know if you need further information. I am using SharePoint 2013 server and Forms Designer 3.1.4.
Thanks
Andy
EDIT - I think I fixed it by adding this into the new form and setting the lookup field with parentId:
var parentId = $('.ms-dlgFrame', window.top.document)[0]
.contentWindow.GetUrlKeyValue('ID');
But please tell me if I'm doing this wrong!