cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

"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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
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}
)

View solution in original post

4 REPLIES 4
Highlighted
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}
)

View solution in original post

Highlighted
Super User
Super User

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!

Highlighted
Super User
Super User

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 @Anonymous's last reply here: https://community.powerapps.com/t5/Connecting-to-Data/The-first-argument-of-Remove-should-be-a-collection/m-p/93838/highlight/true#M1031

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}
)

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (4,232)