pre populating a related items field

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
jpwallace
Posts: 47
Joined: Fri Mar 03, 2017

09 Feb 2017

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

jpwallace
Posts: 47
Joined: Fri Mar 03, 2017

09 Feb 2017

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

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

09 Feb 2017

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:

Code: Select all

fd.field('FieldName').value(val);

jpwallace
Posts: 47
Joined: Fri Mar 03, 2017

09 Feb 2017

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

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

09 Feb 2017

If you need to populate a lookup to the parent item, please, read the post:

http://spform.com/office-365/crea ... office-365

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests