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 / For all, patch and Lookup
Power Apps
Answered

For all, patch and Lookup

(0) ShareShare
ReportReport
Posted on by 62

HI:

 

I'm tring to automaticly create new records on a sharepoint list(list_a), base on the quantity and values of a filter gallery(Gallery4).

 

This next example works fine, creating the records I want each one with the one of the values(value_1) of the Gallery4

 

ForAll(
Gallery4.AllItems;
Patch(
'list_a';
Defaults('list_a');
{value_1=Subtitle3.Text)}
)
)

 

Now I want to substitude value_1 with a lookup value(lu_value) to another list, si I have tried something like this:

 

ForAll(
Gallery4.AllItems;
Patch(
'list_a';
Defaults('list_a');
{lu_value=Subtitle3.Text)}
)
)

 

With htis, I get an error saing the lu_value is expecting a record and is getting a number, so i have tried this:

 

ForAll(
Gallery4.AllItems;
Patch(
'list_a';
Defaults('list_a');
{lu_value=Lookup('list_b'; ID=Subtitle3.Text)}
)
)

 

With this I get an error, saying that lu_value is expecting another kind of record, though lu_value is a lookup field to "list_b".....

 

Any clue how to solve this?

 

Thanks in advance.

Categories:
I have the same question (0)
  • cholopa Profile Picture
    62 on at

    Notice in our country we use ";" instead of ","

  • Verified answer
    WarrenBelz Profile Picture
    156,454 Most Valuable Professional on at

    Hi @cholopa ,

    A Lookup field is actually a Table consisting of the ID of the record chosen in the "other" list and the value in the nominated field that record. To Patch to a Lookup field, you need both of those values.

    Currently it seems you have a free-form Text field, so for a start unless the value put in there exactly matches one of the values in the Lookup column, you will not be able to Patch it. If it does match, the syntax would be

    ForAll(
     Gallery4.AllItems;
     Patch(
     'list_a';
     Defaults('list_a');
     {
     lu_value:
     {
     Value:Subtitle3.Text;
     Id:
     Lookup(
     'list_b'; 
     FieldName=Subtitle3.Text
     ).ID
     }
     }
     )
    )

    FieldName is the field in list_b being looked up.

     

    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.

  • cholopa Profile Picture
    62 on at

    Hi:

     

    Work fine!!!

    Thanks very much!!!!

     

    Just a notice, I had to also add value to Subtitle.Text for it to work properly (to change a text for a number)

     

    Here is the final code(remember ";" is subsitute by "," in my country.:

     

    ForAll(
     Gallery4.AllItems;
     Patch(
     'Mnto equipos basicos';
     Defaults('Mnto equipos basicos');
     {
     LU_equipo:
     {
     Value:LookUp(Equipos;ID=Value(Subtitle3.Text)).codigo_x0020_cliente;
     Id:LookUp(Equipos;ID=Value(Subtitle3.Text)).ID 
     }
     }
     )
    )



     

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 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard