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 / How to update other fi...
Power Apps
Answered

How to update other fields based on one text field?

(0) ShareShare
ReportReport
Posted on by 247

I am not sure how to update the table "WorkingUnit" in SQL database when user input field UnitID changes in Gallery1:

 

       1. Change the value in UnitID text field

       2. Lookup data from SQL data table "UnitInfo" for UnitName, AKA, Status, StartDate and EndDate

        3. Patch data to table "WorkingUnit".

 

For OnChange property of UnitID field: Collect(UnitInfo_Collection, LookUp('[dbo].[UnitInfo]', UnitID = UnitID.Text)); Patch('[dbo].[WorkingUnit]', ThisItem, {UnitID: UnitInfo_Collection.UnitName})

 

I got error saying expected type text, found table. I just need to use the first row in the collection (lookup always returns one row), how do I tell it to use the first row? Thank you in advance for your help!   

 

 

 

 

 

 

Categories:
I have the same question (0)
  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    If you are looking to get the first record of UnitInfo_Collection then it would be First(UnitInfo_Collection) and if you wanted just the UnitName value of the first record it would be (UnitInfo_Collection).UnitName

  • Verified answer
    v-siky-msft Profile Picture
    on at

    Hi @NewBee117 ,

     

    The cause of your issue is that the UnitID you want to patch should be a value, however what you put (UnitInfo_Collection.UnitName) is a table.

    Collect function you use will add records to the existing collection, so it returns a table. And the latest record is in the last column

    So you should modify your formulas as below:

    Collect(UnitInfo_Collection, LookUp('[dbo].[UnitInfo]', UnitID = UnitID.Text)); Patch('[dbo].[WorkingUnit]', ThisItem, {UnitID: Last(UnitInfo_Collection).UnitName})

    NOTE: If you want collection always only saves the current record, please try ClearCollect function. 

     

    Best regards,

    Sik

     

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard