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 / Patch Dataverse Table ...
Power Apps
Answered

Patch Dataverse Table with Lookup Columns from Collection

(0) ShareShare
ReportReport
Posted on by 321

I have one Table in Dataverse (Manhours) with following columns:

ashokpershad_2-1635839721793.png

 

Now I used one FORM with this table as Datasource. When I press one submit button after filling details in this form I am creating one collection (displayed in Gallery5) where I am storing all  FORM submit entries. Please note this Submit button actually not for SUBMITFORM function. It is only for submitting new entries in collection.

Gallery5:

ashokpershad_1-1635839285445.png

Now I want to Patch this Gallery back to my Dataverse Table using this ForAll and Patch functions. 

I used Following Formula:

 

 

 

ForAll(Gallery5.AllItems, Patch(Manhours, Defaults(Manhours), {WOrder:glry5WO.Text, 'Lab Supervisor':LookUp(Manhours, 'Lab Supervisor'.Supervisor = glry5Sup.Text), 'Service Engineer': LookUp(Manhours, 'Service Engineer'.'Engineer Name' = glry5eng.Text), 'Date Started':glry5DS, 'Date Completed': glry5DE, 'Actual Work Hours': glry5AH.Text, Remarks: glry5Remarks.Text}))

 

 

 

But this formula is showing following error:

ashokpershad_0-1635841333172.png

 

What formula shall I use? 

 

I hope its clear.

 

  • Drew Poggemann Profile Picture
    9,287 Most Valuable Professional on at

    Hi @ashokpershad ,

     

    Looking at your patch function should your lookups be actually going against the User table?

    ForAll(Gallery5.AllItems, Patch(Manhours, Defaults(Manhours), {WOrder:glry5WO.Text, 'Lab Supervisor':LookUp(Users, 'Full Name' = glry5Sup.Text), 'Service Engineer': LookUp(Users, 'Full Name' = glry5eng.Text), 'Date Started':glry5DS, 'Date Completed': glry5DE, 'Actual Work Hours': glry5AH.Text, Remarks: glry5Remarks.Text}))

    Not sure if the above is the right adjustment but overall you have two lookup columns for the Lab Supervisor and Engineer and I would expect you are trying to find the Users table value for these to populate in the field?  In this case I think your lookup needs to go against that table vs. your Manhours table.

     

    Hope this helps.  Please accept if answers your question or Like if helps in any way.


    Thanks,


    Drew

  • ashokpershad Profile Picture
    321 on at

    Dear @dpoggemann 

    Someone suggested me this way to deal with Lookup when patching but it seems this is not the right way. Ignore my Formula... Could you please suggest what should be the best solution to patch this collection back to ManHours table in dataverse ?

  • Drew Poggemann Profile Picture
    9,287 Most Valuable Professional on at

    Hi @ashokpershad ,

     

    Are the lookup columns for the engineer and the supervisor to the Users table?  If they are you might want to try the code I put in there above...  


    A good article showing how to patch some of the more complex types is here:  http://powerappsguide.com/blog/post/dataverse-how-to-patch-the-5-most-complex-data-types 

     

    Hope this helps.  Please accept if answers your question or Like if helps in any way.


    Thanks,

    Drew

     

  • Verified answer
    Ram Prakash Duraisamy Profile Picture
    5,891 Super User 2026 Season 1 on at

    Hello @ashokpershad,

     

    Can you please try the same below

     

    ForAll(Gallery5.AllItems, Patch(Manhours, Defaults(Manhours), {WOrder:glry5WO.Text, 'Lab Supervisor':LookUp(Manhours, Name = glry5Sup.Text), 'Service Engineer': LookUp(Manhours, Name = glry5eng.Text), 'Date Started':glry5DS, 'Date Completed': glry5DE, 'Actual Work Hours': glry5AH.Text, Remarks: glry5Remarks.Text}))

     

    Name --> It should be Primary Name Field in the Lookup Entity

     

    Please mark as Answer if it is helpful and provide Kudos


    Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
    Blog : https://microsoftcrmtechie.blogspot.com

     

  • Drew Poggemann Profile Picture
    9,287 Most Valuable Professional on at

    Hi @rampprakash,


    The lookup for the users wouldn't be to the Manhours table I wouldn't think...  I assume they would be looking at the Users table for the Supervisor and Engineer so that is why I changed the code to do lookup like the following for those two that are like this one...  Does this make sense as the right change to you?  

    'Service Engineer': LookUp(Users, 'Full Name' = glry5eng.Text)

    Thanks,

    Drew

  • Ram Prakash Duraisamy Profile Picture
    5,891 Super User 2026 Season 1 on at

    Hello @dpoggemann,

     

    If @ashokpershad need to fetch User then your code is perfectly correct. If he is expecting from custom entity then he can look at my code

  • ashokpershad Profile Picture
    321 on at

    Dear @rampprakash  and @dpoggemann 

    Thank you for your replies. 

    Let me clarifies few things. Both my Supervisor and Engineer tables are custom tables with data like name, emails company etc. Have a look at below tables screenshot:

    SUPERVISOR TABLE:

    ashokpershad_0-1635922751817.png

    ENGINEER TABLE:

    ashokpershad_1-1635922805077.png

     

    @rampprakash  I have tried adding same formula as you advised:

     

     

    ForAll(Gallery5.AllItems, Patch(Manhours, Defaults(Manhours), {WOrder:glry5WO.Text, 'Lab Supervisor':LookUp(' Abc Supervisors', Supervisor = glry5Sup.Text), 'Service Engineer': LookUp('Service Engineers', 'Engineer Name' = glry5eng.Text), 'Date Started':glry5DS, 'Date Completed': glry5DE, 'Actual Work Hours': glry5AH.Text, Remarks: glry5Remarks.Text}))

     

     

    There is NO errors now except one delegation warning. How can we remove this warning.

     

    ashokpershad_1-1635925275392.png

     

    Only thing now, the data is not patching in the Manhours Table. Table is still not updating any data after pressing this Patch button.

    In Manhours I have total 7 columns which I am already using in Patching. 

    Thank you for your patience but this issue is taking too long to resolve.

     

     

  • Drew Poggemann Profile Picture
    9,287 Most Valuable Professional on at

    Hi @ashokpershad ,

     

    I would try the following to break this down:

    Create this outside of the ForAll:

    1.  Add fields to your Canvas App to store Lookup values of your Engineer and Supervisor

    2.  Manually pass in the values for one of the rows to these Lookups and verify they return what you are expecting

    3.  Set all the fields in the patch manually from values of one of the records and verify you can get this patch to work. 

    4.  Once you have patch working for 1 record then we can analyze the ForAll.

     

    Hope this helps to identify the source of the issue.


    Thanks,

     

    Drew

     

     

  • ashokpershad Profile Picture
    321 on at

    @dpoggemann 

    I tried but there is some error coming:

    ashokpershad_0-1635935013180.png

    This error coming after i press the Patch submit button. Before pressing button this error is not showing in formula section.

    Everything seems fine but still not resolved.

    Sorry now its becoming very frustrating.

    Thanks

     

  • Verified answer
    Drew Poggemann Profile Picture
    9,287 Most Valuable Professional on at

    Hi @ashokpershad ,

     

    Please review the following article and try doing a validation or handling the errors and see if you get better information.  

    https://matthewdevaney.com/power-apps-patch-function-error-handling/ 

     

    Thanks,

     

    Drew

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 396 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard