web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / using patch to insert ...
Power Apps
Answered

using patch to insert record with 1:N relationship

(0) ShareShare
ReportReport
Posted on by 7

Hello, I have the following problem. I have two lists in sharepoint, one called tbUnit and another called tbStock.
In tbStock I have the following fields:
ID: autoincrement
Size: Text
Quantity: Number
UniformId: Number
Unit: Lookup (lookup on the ID field of the tbUnit table)
Unit:Name: "Unit Name"

In tbUnit I have the following fields:

ID: autoincrement
Name: Text

I'm trying to insert a record in tbStock with the following command:

 

 

 

Patch(tbEstoque;
 Defaults(tbEstoque);
 {
 Tamanho: txtTamanho.Selected.Nome;
 Quantidade: Value(txtQuantidade.Text);
 IdUniforme: Value(txtIdUniforme.Text);
 Unidade: {
 Value: txtUnidade.Selected.Nome;
 Id:LookUp( 
 tbUnidades; 
 Nome=txtUnidade.Selected.Nome
 ).ID
 }
 }
) 

 


The above command is not generating an error, but the inserted record has a blank value in the field Unit of tbStock. Could you guide me why this error is occurring?




Thanks!

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    Hi @isaac_sampaio ,

    In your screenshot, I can only see a number in Unidade - if the Unidade:Nome beside it is a secondary lookup (please post a screenshot of your Lookup field setting), you cannot patch to them, in fact the whole Lookup column structure is generally unnecessary with Power Apps and will only cause you unwanted grief.

  • isaac_sampaio Profile Picture
    7 on at

    Hi, @WarrenBelz, Below is the configuration image of the Unit field (lookup), as requested.

    Screenshot 2023-06-17 060320.jpg

     

     

  • Verified answer
    WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    @isaac_sampaio ,

    I suspected that - you only need to post the ID - you cannot post anything to the secondary lookup. Also I would not recommend that structure. If you must use lookup columns for something direct in SharePoint (I never have and most likely never will use them), display the actual Name column and then lookup the ID the way you have in your post.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard