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

"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
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
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

seadude
Level 10

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 10

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...

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 353 members 5,594 guests
Please welcome our newest community members: