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

Creating child rows where foreign key is defined by Sharepoint Lookup column

hi folks,

fairly new to powerapps, but have managed to create an app that displays a sharepoint list and drills down into a child sharepoint list (all the filtering to show only child rows is working fine).  The child sharepoint list has field, Project, that defines the relationship:

1) editing existing child rows works fine

2) creating new rows when at least one child row already exists work fine;

    this works because i can pass in a reference to the structure of the Sharepoint lookup column "Project", as follows:

       NewForm(edtIssueForm);Navigate(edtIssue, ScreenTransition.None,{prjRowNew: BrowseGallery2.Selected.Project})

   the editform receives the Project values for {@odata.type, ID, Value} and sets them correctly on the new edit form.  works great.

3) creating a new row if there aren't any existing child rows, i cannot figure out how to setup the Project lookup column structure and default values.  in the edit form, the dropdown works to select the Project value, but would rather not have to, since i know what the values of ID and Value are, but cannot set them and have been spending hours hacking at what seems like it should be pretty straightforward.

 

Can anyone help me understand how to create a new row with a defaulted value for the complex lookup type?  

 

Thank you

 

Can anyone point me in the right direction?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff rgruian
PowerApps Staff

Re: Creating child rows where foreign key is defined by Sharepoint Lookup column

You are stating you need to "default it somehow", but what should the experience be?

 

In the target screen, you have set the form to New mode, which means all fields will be empty, because you are adding a new row to the data source (Models, presumably). If the form is configured correctly, it will allow you to select the Make in that form via a lookup control that is bound to the Make field. If you are asking whether it's possible to start with a non-empty lookup value for that field when adding a new row/entry in the Models data source, the answer is "no" currently.

 

Radu Gruian [MSFT] ** PowerApps Staff
10 REPLIES 10
Community Support Team
Community Support Team

Re: Creating child rows where foreign key is defined by Sharepoint Lookup column

Hi Timm,

 

Do you create an App from data with SharePoint Online list? There are child rows in your SharePoint list, to reproduce this issue, could you provide steps of how you created child rows in your SharePoint list?

 

Best regards,
Mabel Mao

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
timm
Level: Powered On

Re: Creating child rows where foreign key is defined by Sharepoint Lookup column

Hi, 

 

Here's the structure of the Sharepoint lists, basically:

ERD.PNG

 

In Sharepoint, the internal structure of all lookups columns is {@odata.type, Value, Id}.

 

In PowerApps, on the edit form, this is what the data card looks like.

Datacard1.PNG 

 

the sequence of events is:

1) browse the care "Makes" (Ford, Chevrolet, BMW, etc)

2) view a list of Models

 

 

when creating a new Model, I want to set/default the value of the Model.Make lookup field.  If i just set Value and/or Id, the information does not save correctly.  If i manually select something from the dropdown, it's working fine.

 

It's so simple a question, basically how do you set the values of a Sharepoint lookup column?

 

Thanks folks,

Tim 

timm
Level: Powered On

Re: Creating child rows where foreign key is defined by Sharepoint Lookup column

Yes, i created the base app from a sharepoint list.  Then i proceeded to add new screens to display related child lists.  

 

When trying to add related child List records, i am trying to set the value of the child lists' Sharepoint Lookup column.  I cannot figure out how to set the values.  Basically just looking for some sample code on how to handle adding a child record to a sharepoint list where the foreign key is a lookup column and defaulting that Sharepoint Lookup column  (which is a complicated data type of {@odata_type, Value, Id})

 

The step for creating a child record is 

NewForm(edtIssueForm);Navigate(edtIssue, ScreenTransition.None,{prjRowNew: BrowseGallery2.Selected.Project})

 

that line of code works great if there is a "selected" row.

 

if there are no rows in the BrowseGallery2, the "Selected.Project" is blank and i need to default it somehow - i can't figure out how to set it.

 

it's probably so simple that it's just setting a value of a variable, but

1) i don't understand how to set those variables

2) or where to set them.

 

Thank you,

Tim

PowerApps Staff rgruian
PowerApps Staff

Re: Creating child rows where foreign key is defined by Sharepoint Lookup column

You are stating you need to "default it somehow", but what should the experience be?

 

In the target screen, you have set the form to New mode, which means all fields will be empty, because you are adding a new row to the data source (Models, presumably). If the form is configured correctly, it will allow you to select the Make in that form via a lookup control that is bound to the Make field. If you are asking whether it's possible to start with a non-empty lookup value for that field when adding a new row/entry in the Models data source, the answer is "no" currently.

 

Radu Gruian [MSFT] ** PowerApps Staff
timm
Level: Powered On

Re: Creating child rows where foreign key is defined by Sharepoint Lookup column

Thank you Radu

 

It's not the answer that anyone making apps utilizing SharePoint lists with more than one list wants to hear, but at least i can stop trying to do something that is not possible.

 

Is setting a value in a lookup column on the roadmap?

 

What is very odd to me, is that if there's already a "model" associated with the "make", it IS possible to set the default value on a new row.  It really doesn't stand to logic?!

aidangarnish
Level: Powered On

Re: Creating child rows where foreign key is defined by Sharepoint Lookup column

Is there any change on this? It sounds like it isn't currently possible to create a child object and automatically connect it to the parent which is a huge limitation for Power Apps.

Highlighted
sfishe
Level: Powered On

Re: Creating child rows where foreign key is defined by Sharepoint Lookup column

I'm having the same questions (I think)

 

Has anyone got fresh ideas on this? It seems like a basic feature of relational databases that's missing here.

 

In my case I'm using a gallery to select a parent record, and then want to create a child record that is obviously linked to the parent (i.e. the foreign key is set). It's the sort of thing Access Web Apps did automatically, but it seems PowerApps needs to be forced to do it manually somehow

CJEales
Level: Powered On

Re: Creating child rows where foreign key is defined by Sharepoint Lookup column

I have the same scenario and have been working on it for the last week. I have finally managed to create the new item in the child table using MICROSOFT FLOW, using PowerApps as the trigger and the source of the data. You can use "GET ITEM" action to retrieve the parent ID from Sharepoint Lists and apply this to the foreign key in the child item.

Hope this helps!

javierC
Level: Powered On

Re: Creating child rows where foreign key is defined by Sharepoint Lookup column

Can you please provide  more deatails about your Flow solution?

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

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

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 370 members 4,688 guests
Please welcome our newest community members: