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

Not Working Lookup with 2 lists

Hello!

 

 I'm creating a repeat table, with Gallery and Patch in Power Apps, where I have 2 Sharepoint lists.

1- Recipe
2- Recipe Products

 

I used a material provided by Shane, where you have everything step by step, I have already created the form for inserting the data of the Recipe, as well as the gallery for the products.
With the help of a collection, I extract the data from the gallery, and in the ONSUCESS step of the Form (recipe), I launch the ForAll with the Patch, to launch the product data.

The problem that when referencing the field of Lookup, it is presenting an error message in the formula used in the OnSucess form: The type of this argument 'PratoID' does not match the expected type 'Record'. Found type 'Number'

 

In the Formula I use the LastSubmit.ID to retrieve the ID from the Recipe List:

 

 Forall (
     Products;
     Patch ('Products for Revenue'; Defaults);
    {Title: Code; DescProd: Description, PratoID: Form1.LastSubmit.ID}
  )
)

 

Remembering that it has a save button that gives the submit in main form.

(I am using the global standards, since I am located in Latin America)

1 ACCEPTED SOLUTION

Accepted Solutions
KroonOfficeSol
Level 10

Re: Not Working Lookup with 2 lists

@Macoppi

 


Oké, let me explain a little deeper then. In your SharePoint list (lets call this list one) you have a column which is a lookup to the Prato list (list2). In SharePoint this is not an number field/Integer like it would be in a SQL database, but a compleet record. When you made this LookUp column you are ask which fields from List2 you would like to show in List1, this is the schema list1 contains.

 

When you work from SharePoint on one record this can be a good thing, because you can drill down from to column to all the fields in the related column. This makes it a complex field. For PowerApps this give problems and on the board you see this all the time, almost all Sharepoint related questions are on delegation issues.

 

Knowing this and looking at your error. The PratoID field is a record from list1, so when you like to write a value to this column is has to be a representation off a record from list1.

 

What you could try is first to patch Inputdados.LastSubmit (so without the .ID) to the field. Do like this:

UpdateContext({_LastSubmittedItem:InputDados.LastSubmit})
;ForAll(Productos,Patch(List2, { all your things, PratoID:_LastSubmittedItem}))

If this doesn't work then use the ShowColumns() formula to change the schema for the variable. Change the first line:

UpdateColumns({_LastSubmittedItemSmiley FrustratedhowColumns(Inputdados.LastSubmitted, Column1, Column2,...)})

The schema you have to figure out yourself. But a way could be to create a form, connect this to list1 and see how the choice() are on the dropdown which gets created by PowerApps automatically.

 

Hope this brings you further.

 

Paul
 

5 REPLIES 5
KroonOfficeSol
Level 10

Re: Not Working Lookup with 2 lists

@Macoppi,

 

First, change to English as default languages in your development environment. You could use Quick Language changer as add-in in Chrome. 

 

For your question: the PratoID wants a record, so I would think this field is a lookup from another list is this correct.  This mean you have to give the Patch a object with the same schema as your field wants to get.

 

You can use the LookUp() formula on the lookup list to find the wanted object and the ShowColumns() formula to return only the fields required. 

 

Hope this helps,

 

Paul

Macoppi
Level: Powered On

Re: Not Working Lookup with 2 lists

Thanks for the feedback Paul!

 

I applied Quick Language, and it helped me a lot. But the main mistake still continues.

 

In the same Screen I create the Master item and the children from a save button, which gives a submit in the main form, and in OnSucess, it triggers the creation of the items in the other list, retrieving the ID through LastSubmit.

 

 

 

I'm using Shane's material as support!  https://www.petri.com/create-infopath-repeating-tables-sharepoint-powerapps

KroonOfficeSol
Level 10

Re: Not Working Lookup with 2 lists

Read the rest off my answer and do a lookup. Store the LookUp in a varible with UpdateContext(), then call the forall() and use this variable in the patch().
Macoppi
Level: Powered On

Re: Not Working Lookup with 2 lists

I need to know these functions you passed (I am a beginner in powerapps), what struck me most is that I followed exactly the step by step, and returned that error.

 

Tks a lot! 

KroonOfficeSol
Level 10

Re: Not Working Lookup with 2 lists

@Macoppi

 


Oké, let me explain a little deeper then. In your SharePoint list (lets call this list one) you have a column which is a lookup to the Prato list (list2). In SharePoint this is not an number field/Integer like it would be in a SQL database, but a compleet record. When you made this LookUp column you are ask which fields from List2 you would like to show in List1, this is the schema list1 contains.

 

When you work from SharePoint on one record this can be a good thing, because you can drill down from to column to all the fields in the related column. This makes it a complex field. For PowerApps this give problems and on the board you see this all the time, almost all Sharepoint related questions are on delegation issues.

 

Knowing this and looking at your error. The PratoID field is a record from list1, so when you like to write a value to this column is has to be a representation off a record from list1.

 

What you could try is first to patch Inputdados.LastSubmit (so without the .ID) to the field. Do like this:

UpdateContext({_LastSubmittedItem:InputDados.LastSubmit})
;ForAll(Productos,Patch(List2, { all your things, PratoID:_LastSubmittedItem}))

If this doesn't work then use the ShowColumns() formula to change the schema for the variable. Change the first line:

UpdateColumns({_LastSubmittedItemSmiley FrustratedhowColumns(Inputdados.LastSubmitted, Column1, Column2,...)})

The schema you have to figure out yourself. But a way could be to create a form, connect this to list1 and see how the choice() are on the dropdown which gets created by PowerApps automatically.

 

Hope this brings you further.

 

Paul
 

Helpful resources

Announcements
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

Users Online
Currently online: 280 members 4,922 guests
Please welcome our newest community members: