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 / The datasource supplie...
Power Apps
Unanswered

The datasource supplied to the function is invalid

(1) ShareShare
ReportReport
Posted on by 8

Hi Team,

I have a collection and a gallery. In the gallery when a user fills a record I have a save button next to each record and once the user selects the save button that particular gallery record should get added to the collection. I'm creating the collection on the Onvisible property of the screen:

 

ClearCollect(
 colDevices,
 {
 Device: "",
 Status:"",
 Operator:"",
 Location: "",
 Description: ""
 }
)

 

Now when a user tries to click the save button the following code is giving an error "The data source supplied to the function is invalid"

 

Patch(
 colDevices,
 ThisItem,
 {
 Device: drpDevice.Selected.Value,
 Status: drpDeviceStatus.Selected.Value,
 Operator:If(!IsEmpty(cmbOperator.Selected.Mail),cmbOperator.Selected.Mail,""),
 Location:txtLocation.Text,
 Description:txtDescription.Text
 }
);

Collect(colDevices, {
 Device: "",
 Status: "",
 Operator: "",
 Location: "",
 Description:""
 })

 

 

My gallery:
b6cbe110-8a97-4334-9af8-ae61f72030da.PNG

 

Please help me with this issue. Why am I getting this error. I was following Shane Young's video for this:
PowerApps Repeating Tables like InfoPath Part 1 

Categories:
  • Ethan_009 Profile Picture
    4,840 Moderator on at

    Hi @kund14 ,

     

    What's the error that you are getting?

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Ethan_R Probably the title of the thread, I think
    "The datasource supplied to the function is invalid"

     

     

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @kund14 

     

    Based on your description, it seems like you're trying to use Patch function to update a local collection (colDevices), but you're getting the "The data source supplied to the function is invalid" error.

     

    This could be because Patch function is mainly used to modify specific records in a data source. In your case, you're trying to modify a record in a local collection, which might not be a valid use of Patch.

     

    Instead, you should use Collect or UpdateIf for adding/updating data in a local collection. For example, you could use:

    Collect(
     colDevices, 
     {
     Device: drpDevice.Selected.Value,
     Status: drpDeviceStatus.Selected.Value,
     Operator:If(!IsEmpty(cmbOperator.Selected.Mail),cmbOperator.Selected.Mail,""),
     Location:txtLocation.Text,
     Description:txtDescription.Text
     }
    )
    

     

    This Collect function will add a new record to the colDevices collection each time the save button is clicked.

    However, if you want to update a specific record in the colDevices collection instead of always adding a new record, you could use UpdateIf function:

     

    UpdateIf(
     colDevices, 
     ThisItem,
     {
     Device: drpDevice.Selected.Value,
     Status: drpDeviceStatus.Selected.Value,
     Operator:If(!IsEmpty(cmbOperator.Selected.Mail),cmbOperator.Selected.Mail,""),
     Location:txtLocation.Text,
     Description:txtDescription.Text
     }
    )

     

    This UpdateIf function should update the current record (ThisItem) in the colDevices collection with the new values when the save button is clicked.

     

    You should try and replace Patch function with either Collect or UpdateIf depending on whether you want to always add a new record or update the existing record.

     

    If I understood correctly I believe Patch function is for updating data in a data source (like a table in a database), and not for a local collection in PowerApps.


    See if it helps @kund14 

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 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 239

Last 30 days Overall leaderboard