cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TrueGrit
Level: Powered On

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.

 

 

12 REPLIES 12
Dual Super User
Dual Super User

Re: Setting parent ID on a child form?

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.
TrueGrit
Level: Powered On

Re: Setting parent ID on a child form?

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.

Dual Super User
Dual Super User

Re: Setting parent ID on a child form?

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.
TrueGrit
Level: Powered On

Re: Setting parent ID on a child form?

 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. 

 

 

 

 

Dual Super User
Dual Super User

Re: Setting parent ID on a child form?

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.
TrueGrit
Level: Powered On

Re: Setting parent ID on a child form?

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
Level: Powered On

Re: SettIing parent ID on a child form?

 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

Dual Super User
Dual Super User

Re: SettIing parent ID on a child form?

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.
JasonF
Level: Powered On

Re: SettIing parent ID on a child form?

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
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Kudoed Authors
Users Online
Currently online: 289 members 5,612 guests
Please welcome our newest community members: