Create master/detail record with related-items

rss

Posted by Dars - Apr 12 ’16 at 01:02

Hello,

 

I'm trying to see how the related-items works and even though I've read quite a few blog entry, I can't seems to figure it out :(

I'm trying to accomplish a master/detail scenario.  As an example: Purchase Order / Purchase Order Items

So I have two lists.  The Purchase Order Items list have a PO_id lookup field which refers to Purchase Order -> ID field.

So on my form for Purchase Order, I have a few fields and also the related-items control.  From the following blog-entry http://formsdesigner.blogspot.ca/2015/09/inline-spreadsheet-style-edit-mode-for.html I created the javascript snippet

fd.populateFieldsInGrid($('.related-items'), {

TransfertQuartID: GetUrlKeyValue('ID'),

});

and also identified "related-items" to the CSS class of the related-items control.

It's not working and I also don't understand why it would because the GetUrlKeyValue('ID') should not return anything until my parent record is saved, isn't??

Thank you.

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 7 months 4 days
    #1 by rostislav Apr 13 ’16 at 04:50

    Hello,

    You're right,  GetUrlKeyValue('ID') doesn't return anything if you're on the new item form as the item hasn't yet been created and its ID assigned, so please refer to this blog post http://formsdesigner.blogspot.com/2015/11/add-related-items-on-new-sharepoint-form.html. You seem to be doing everything correctly, only you need to use the {CurrentItem} token and make sure you're using the correct internal name of the field.

  • Dars
    Member
    Member for: 5 years 8 months 1 day
    #2 by Dars Apr 13 ’16 at 08:24

    Hmmm, Ii still can't get it to work :(

    I'm sure it's a 15 inches problem (15 inches in front of the screen) but can't figure it out even though it seems quite simple.  Here is my setup, we can see my class assigned and also the javascript portion:

     

     

    and this is what I get when trying to save:

     

     

    Thanks for the help

  • Dars
    Member
    Member for: 5 years 8 months 1 day
    #3 by Dars Apr 13 ’16 at 08:28

    Ok, can't figure how to add image too :(

     

    So here's my javascript snippet:

    fd.populateFieldsInGrid($('.related-items'), {

    TransfertQuartID: '{CurrentItem}',

    });

     

    I have "related-items" CSS class defined under Layout.

    My related-items control  Quick Edit property is set to "Only"

    Whenever I save the record, I get the following message: "The list item could not be inserted or updated because invalid lookup values were found for the following fiel(s) in the list: [TransfertQuartID].

  • Dars
    Member
    Member for: 5 years 8 months 1 day
    #4 by Dars Apr 13 ’16 at 08:28

    Ok, can't figure how to add image too :(

     

    So here's my javascript snippet:

    fd.populateFieldsInGrid($('.related-items'), {

    TransfertQuartID: '{CurrentItem}',

    });

     

    I have "related-items" CSS class defined under Layout.

    My related-items control  Quick Edit property is set to "Only"

    Whenever I save the record, I get the following message: "The list item could not be inserted or updated because invalid lookup values were found for the following fiel(s) in the list: [TransfertQuartID].

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 7 months 4 days
    #5 by rostislav Apr 14 ’16 at 06:28

    [#4]:

    Make sure:

    - you're using the correct internal name of the lookup field name (check “from the browser” section on this page http://techtrainingnotes.blogspot.com/2012/10/sharepointfinding-column-display-and.html )

    - the lookup field points to the ID field of the correct list

  • Dars
    Member
    Member for: 5 years 8 months 1 day
    #6 by Dars Apr 14 ’16 at 07:48

    [#5]:

    Everything seems to be setup properly.  My lookup field on my "detail" list refers to the ID of the "header" list.

    What I have just noticed is that if I create a new entry, specify only the information for the header and nothing for my "detail" list (therefore entering nothing in the related-items control) and then save the entry.  Then I get my record created in my master list.  If I edit this record and then enter data in my related-items control, the TransfertQuartID gets populated with the ID from the master list.

    The only Javascript I have in my form is the following:

    fd.populateFieldsInGrid($('.related-items'), {

    TransfertQuartID: '{CurrentItem}',

    });

    Unless I'm mistaken, it should work in New and Edit mode as per your previous comments about using {CurrentItem} rather than [ID] since it doesn't exist yet at the creation of a new entry.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 8 years 2 months 19 days
    #7 by Dmitry Kozlov Apr 14 ’16 at 09:18

    [#6]: Hi,

    What edition of SharePoint do you use: online or on-premises? What's your version of Forms Designer (you can find it in the lower right corner of the designer)? Is it possible to provide temporary access to the form?

  • Dars
    Member
    Member for: 5 years 8 months 1 day
    #8 by Dars Apr 14 ’16 at 09:23

    [#7]:

    I use Forms Designer 3.0.6 and we are using Sharepoint 2013 Foundation on-premise.

    I could arrange a Go-to meeting and share my screen if you want?

    Thank you.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 8 years 2 months 19 days
    #9 by Dmitry Kozlov Apr 14 ’16 at 09:30

    [#8]: Yes, please, drop the connection settings to [email protected]

Displaying 1 to 9 of 9 messages