cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
seadude
Level 8

"Data source supplied to the function is invalid" error when Patching an Image

Scenario:

  • Create a Collection OnStart of app:
  • Collect(collection,
        {
         user:    " ",
         notes:  " ",
         image: " ",
         date:    " ",
         time:    " "
        })
  • User clicks "take picture" button
  • Image ("takenPicture") overlays the camera control with still image
  • User clicks "save picture"
  • The Patch code for "save picture" is:
  • Patch(collection,
        {image: takenPicture.Image})
  • The still picture (takenPicture.Image) is not Patched into the collection.
  • An error on the "save picture" button shows:
  • Screenshot from 2018-05-12 21-37-00.png
  • The Patch code is now underlined in red squiggles with the same error:
  • Screenshot from 2018-05-12 21-39-04.png

 

Why is this happening and how can I overcome it?

 

Thank you


Accepted Solutions
Super User
Super User

Re: "Data source supplied to the function is invalid" error when Patching an Image

Hi @seadude

 

The second argument to the Patch function needs to specify the record in the collection that you want to update.

 

Supposing that you want to update the first record (the record that you created in the OnStart of your app), the syntax you would use would look like this:

 

Patch(collection,
      First(collection),
      {image: takenPicture.Image}
)

All Replies
Super User
Super User

Re: "Data source supplied to the function is invalid" error when Patching an Image

Hi @seadude

 

The second argument to the Patch function needs to specify the record in the collection that you want to update.

 

Supposing that you want to update the first record (the record that you created in the OnStart of your app), the syntax you would use would look like this:

 

Patch(collection,
      First(collection),
      {image: takenPicture.Image}
)
seadude
Level 8

Re: "Data source supplied to the function is invalid" error when Patching an Image

This is a great solution @timl, thank you. Do you know of straightforward code that will Lookup a unique record ID and Patch into that record rather than the First?

 

This is a tough scenario that I often encounter and have to hack something together. Would be nice to see others' solutions and develop a standard myself.

 

Example:

  • Data Source:
    • Set a unique identifier in the table by:
      • SQL:
      • Excel:
      • Sharepoint:
  • Patch function which looks up unique identifier and patches record to correct column
    • Patch(Lookup(Sort(Filter(xyz)))

Thanks again!

seadude
Level 8

Re: "Data source supplied to the function is invalid" error when Patching an Image

Figured it out.

 

Needed to set a PK in the SQL Table then refresh Data Source for PowerApps to likey.

 

See @DucMac's last reply here: https://community.powerapps.com/t5/Connecting-to-Data/The-first-argument-of-Remove-should-be-a-colle...

Highlighted
Super User
Super User

Re: "Data source supplied to the function is invalid" error when Patching an Image

Hi @seadude

 

Apologies for not replying sooner. Glad you figured it out! For the benefit of anyone else reading this, the formula would look like this:

 

Patch(collection,
      Lookup(SQLDataSource, UniqueIDColumn=1234),
      {image: takenPicture.Image}
)