Page 1 of 1

Create master/detail record with related-items

Posted: 12 Apr 2016
by Dars
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/0 ... e-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.

Re: Create master/detail record with related-items

Posted: 13 Apr 2016
by rostislav
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/ ... -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.

Re: Create master/detail record with related-items

Posted: 13 Apr 2016
by Dars
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:

Image

and this is what I get when trying to save:

Image

Thanks for the help

Re: Create master/detail record with related-items

Posted: 13 Apr 2016
by Dars
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].

Re: Create master/detail record with related-items

Posted: 14 Apr 2016
by rostislav
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/2 ... y-and.html )

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

Re: Create master/detail record with related-items

Posted: 14 Apr 2016
by Dars
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.

Re: Create master/detail record with related-items

Posted: 14 Apr 2016
by Dmitry Kozlov
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?

Re: Create master/detail record with related-items

Posted: 14 Apr 2016
by Dars
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.

Re: Create master/detail record with related-items

Posted: 14 Apr 2016
by Dmitry Kozlov
Yes, please, drop the connection settings to support@spform.com.