cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TrueGrit
Regular Visitor

Setting parent ID on a child form?

Days wasted on what should be a simple problem to solve...

 

I have a parent SP list and  a child list.  The child needs the ID from the parent.

 

In PA, I have two screens.  Screen 1 allows a user to populate and create an item in the parent SP list. 

 

When navigating to the child screen to create a related item, how does one set the ID of the child item whcn the screen is dsiplayed.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
17 REPLIES 17
Pstork1
Dual Super User
Dual Super User

Do you mean how do you know what the ID of the parent item is when you are on the child screen?  If that's what you are asking then use UpdateContext to set a variable equal to the ID of the parent item when you navigate to the child screen.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

No, not quite.  I know the ID of the parent.  I have that stored in a variable.  I'm trying to set the parent ID on the child screen.

Do you have a particular field where the Parent ID is kept in a child record?  Is there a lookup field in the child record that connects to a specific parent record?  If you don't have a Lookup field defined in the child list then you need to create one.  If you do then review this article for information about how to set the Lookup field in PowerApps.

https://powerapps.microsoft.com/en-us/blog/support-for-lookups/



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

 There IS a lookup field on the child.  It is bound to the ID column on the parent list.  The field renders correctly on  the CHILD form and allows me to select one of the ID's available from the PARENT list.  I can pick any ID and, when the CHILD form is submitted, the correct ID is saved within the CHILD record.  I can therefore successfully create a PARENT / CHILD relationship. 

 

The seemingly impossible task is to have the parent ID set automatically when the CHILD form is opened.  I do not want people to have to pick the PARENT ID to  which a child relates. 

 

 

 

 

Set the default value of the field where you pick the parent ID on the child list to the variable where you save the parent ID.  When you navigate to the child form that should default the ID to the correct value.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

I agree with you, it shoudl indeed be that simple but, after numerous attempts of tyring to do it that way as well as things like {Id: varPArentID.ID} not a single way works.  Even if I set the Default value to a static number, it does NOT set the ID.  

JasonF
Helper III
Helper III

 I think I am having the same problem. Or maybe I should do a separate post on this.

 

Below is the CDS data structure:

Data Structure.JPG

 

I want to create the following data entry form:

Daily Report.png

 

Filling in the DIvision Name is not a problem, but during edit I have to generate the "Report No." (Does not gererate until post) for Daily Reports, Then use that entry in each Revenue entry. I am not thinking this should be so difficult.

 

Regards,

JasonF

OK, I've played around with it a little and this is what I've gotten to work.

 

For the DataValueField in the Data card for the parent List on the new child form set the defaultSelectedItems property to the following:

Choices([@Child].ParentList,Text(ParentID))

Where Child is the name of the child list datasource and ParentID is the name of the context variable that contains the ID of the item in the parent list.  

 

Evidently since its a datacard you have to actually reference the "Choices" enumeration of the Lookup column that is instantiated in the card.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

I think this provided part of my solution for the Revenue detail. However, I still need some way to post the Daily Report to generate the "Report No". Once I have this I can use Default() to fill the Revenus Detail. If I "SubmitForm" after Division Name is selected the I loose the data in the form.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,910)