Page 1 of 1

I can't get these directions to work

Posted: 28 Sep 2017
by smithme
I don't mean to be critical but I have been attempting to follow these directions all day and I still can't get it to work.

https://spform.com/documentation/relate ... gular-mode

For example the instructions tell you to add this to the parent form's JS editor:

Code: Select all

fd.populateFieldsInGrid($('.related-items'), {
	Parent: '{CurrentItem}',
});
Why would I do this?


In the child's new form I am instructed to enter this:

Code: Select all

if (window != window.top && window.top.fd) {
  // the form is opened in a dialog from the parent form
  var parentId = parseInt(window.top.GetUrlKeyValue('ID'));
  if (parentId) {
    // the form is opened from the Edit form
    fd.field('Parent').value(parentId);
  } else {
    // the form is opened from the New form
    $('#_fd_parent_temp > input').val(window.top.fd._tempParentId());
  }
   
  $('.parent-field').hide();
}
Yet I can't get "window.top.GetUrlKeyValue('ID')" to return anything.

Re: I can't get these directions to work

Posted: 28 Sep 2017
by smithme
Correction I finally got "window.top.GetUrlKeyValue('ID')" to return a value.

I am about to set that value to the lookup field.

Re: I can't get these directions to work

Posted: 28 Sep 2017
by smithme
I got it to work but only when I completely abandoned the directions on this page and went with what I knew from previous use of Forms Designer.

Re: I can't get these directions to work

Posted: 29 Sep 2017
by Nikita Kurguzov
Hello, Marion!
The instructions are given, so that this functionality will work on both New and Edit Forms. For Edit Forms, the process is easy since the item is already created and has an ID, it requires very little code to actually work.

The problem comes from the New Form - the Item has no ID yet, so it cannot be bound directly. That is why we store the temporary ID in the hidden field which gets populated once the item is saved. And that's also why you need all this extra code. Hope this makes sense. If you experience any issues, let us know - we'll do our best to help.

You can also follow our video step by step, it's the same as the text instruction, but shows you whole process from the beginning to the end, here - https://www.youtube.com/watch?v=rd8g6Zu1H_E