Page 1 of 1
pre populating a related items field
Posted: 09 Feb 2017
by jpwallace
I have a list with a column that generates a unique number with the help of a workflow. I have this column as a look up in my "main" list.
In my main edit form i have a related items section at the bottom. When i click on new item from the related items section, the form that pops up displays the unique number field as a drop down (showing all records created). I wish to populate this field with the unique reference number of the task im editing, not to have to choose from a dropdown.
I hope all this make sense
Re: pre populating a related items field
Posted: 09 Feb 2017
by jpwallace
looking at the "view source" from the related items form, the column in question shows;
<option selected="selected" value="0">(None)</option>
<option value="126">H0000</option>
<option value="76">H0033</option>
<option value="77">H0034</option>
<option value="78">H0005</option>.........and the list goes on stating all the records that have been added
Re: pre populating a related items field
Posted: 09 Feb 2017
by Dmitry Kozlov
You can retrieve a parent's field from the child form via JavaScript:
Code: Select all
window.top.fd.field('FieldName').value()
Then you just need to assign the retrieved value to the appropriate child's field:
Re: pre populating a related items field
Posted: 09 Feb 2017
by jpwallace
Thanks for getting back so quickly Dmitry,
apologies for my ignorance im new to SPForms, the lookup field i want to pre populate in my related items new form is called TAFNo.
Do i put the following code in the main javascript (toolbar) or when the field is highlighted in the JS from the control section.
window.top.fd.field('TAFNo').value()
fd.field('TAFNo').value(val);
Re: pre populating a related items field
Posted: 09 Feb 2017
by Dmitry Kozlov
If you need to populate a lookup to the parent item, please, read the post:
http://spform.com/office-365/crea ... office-365