pre populating a related items field

rss

Posted by jpwallace - Feb 9 ’17 at 02:40

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
    Member
    Member for: 2 years 11 months 1 day
    #1 by jpwallace Feb 9 ’17 at 02:54

    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

     

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 2 months 18 days
    #2 by Dmitry Kozlov Feb 9 ’17 at 10:24

    [#1]: You can retrieve a parent's field from the child form via JavaScript:

    window.top.fd.field('FieldName').value()

    Then you just need to assign the retrieved value to the appropriate child's field:

    fd.field('FieldName').value(val);
  • jpwallace
    Member
    Member for: 2 years 11 months 1 day
    #3 by jpwallace Feb 9 ’17 at 10:37

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

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 2 months 18 days
    #4 by Dmitry Kozlov Feb 9 ’17 at 11:10

    [#3]: If you need to populate a lookup to the parent item, please, read the post:

    http://formsdesigner.blogspot.com/2013/08/how-to-create-forms-with-related-items.html

Displaying 1 to 4 of 4 messages