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

Announcements

News and Announcements icon
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!

Screenshot 2023-06-16 230940.jpg
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,297 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
    156,297 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 136 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 109 Super User 2026 Season 2

Last 30 days Overall leaderboard