cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
JoAnneCharlotte
Frequent Visitor

Invalid data source for ForAll function (and embedded Patch & Lookup functions)

Hello,

 

I'm trying to create a bulk update on my timesheet data PowerApp. I have a data table, drop downs for filters and then a button called Bulk Edit Status. OnSelect on the button I'm creating a new collection called colFilteredTimesheets - which contains all the currently displayed timesheet entries based on the filters set by the users. I've checked and the collection is being created successfully.

 

My user will then choose a Status value from a drop down box and I want to bulk update all records to the new status. I have the following code on my save button:

 

ForAll(
    RenameColumns(
        colFilteredTimesheets,
        "ID",
        "PT ID"
    ),
    Patch(colFilteredTimesheets,
        LookUp(colFilteredTimesheets,ID = 'PT ID'),
        {Status: drpBulkEditStatus.SelectedText}
    )
)

 

I'm getting an error saying "The data source supplied to the function is invalid".

 

Any suggestions?

 

Thank you 🙂

Jo-Anne

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Invalid data source for ForAll function (and embedded Patch & Lookup functions)

Hi @JoAnneCharlotte ,

Do you want to patch the updated colFilteredTimesheets collection back to your SP List?

 

Based on the needs that you mentioned, I think the ForAll function and Patch function could achieve your needs. On your side, you should type the following formula:

ForAll(
       colFilteredTimesheets,
       Patch(
             'Your SP List',
             LookUp('Your SP List', ID = colFilteredTimesheets[@ID]),
             {
               Title: colFilteredTimesheets[@Title],
               Status: colFilteredTimesheets[@Status],
               ...
               ...
             }
       )
)

 

The above ForAll formula would not cause a Delegation warning issue, the colFilteredTimesheets is a collection, which is not subject to Delegation issue.

Note: The RenameColumns function is not a Delegable function, so please remove the RenameColumns function from your ForAll formula, otherwise, it would cause a Delegation issue.

 

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
Eelman Resident Rockstar
Resident Rockstar

Re: Invalid data source for ForAll function (and embedded Patch & Lookup functions)

@JoAnneCharlotte 

Are you just trying to update 'Status' for all records in your collection (ie colFilteredTimesheets) OR are you attempting to update a data source, such as SharePoint?

 

If you are just updating your collection, something like this should work:

UpdateIf( colFilteredTimesheets, true, {Status: drpBulkEditStatus.SelectedText} )

 

 

JoAnneCharlotte
Frequent Visitor

Re: Invalid data source for ForAll function (and embedded Patch & Lookup functions)

Both eventually. The data is collected in the app, I’m trying to update all records in the collection (code I posted). Once I got that working I will need to sync the updated records in the collection back to SP.
Eelman Resident Rockstar
Resident Rockstar

Re: Invalid data source for ForAll function (and embedded Patch & Lookup functions)

Ok. Did you try the code I posted? Did it work?

JoAnneCharlotte
Frequent Visitor

Re: Invalid data source for ForAll function (and embedded Patch & Lookup functions)

just tried it - no luck - getting a new error "Invalid argument type. Expecting a Record value, but of a different schema."

 

I checked my colFilteredTimesheets collection, it's been created and the Status field is present...

 

Plot thickens! Any other suggestions?

JoAnneCharlotte
Frequent Visitor

Re: Invalid data source for ForAll function (and embedded Patch & Lookup functions)

Update - I've managed to get the ForAll to work - I'm struggling to understand how TBH - I posted last night (early morning) with the issue, then went to bed - came back online and tried the UpdateIF, that didn't work so tried ForAll again and now it works... anyway...

 

Now that my collection is updated I need to send the updates back to the SharePoint list - is ForAll going to work for this or am I am hit delegation issues?

 

Any suggestions for alternatives to save back to SP?

 

Thank you! 🙂

Eelman Resident Rockstar
Resident Rockstar

Re: Invalid data source for ForAll function (and embedded Patch & Lookup functions)

@JoAnneCharlotte 

Could you please post the code you got to work. I suspect you will need to use ForAll and Patch again due to the schema error you were getting.

JoAnneCharlotte
Frequent Visitor

Re: Invalid data source for ForAll function (and embedded Patch & Lookup functions)

Hi - it’s the code in the original post... I’d lost a comma at some point and my data table had a different source so it looked like nothing had happened.
Community Support
Community Support

Re: Invalid data source for ForAll function (and embedded Patch & Lookup functions)

Hi @JoAnneCharlotte ,

Do you want to patch the updated colFilteredTimesheets collection back to your SP List?

 

Based on the needs that you mentioned, I think the ForAll function and Patch function could achieve your needs. On your side, you should type the following formula:

ForAll(
       colFilteredTimesheets,
       Patch(
             'Your SP List',
             LookUp('Your SP List', ID = colFilteredTimesheets[@ID]),
             {
               Title: colFilteredTimesheets[@Title],
               Status: colFilteredTimesheets[@Status],
               ...
               ...
             }
       )
)

 

The above ForAll formula would not cause a Delegation warning issue, the colFilteredTimesheets is a collection, which is not subject to Delegation issue.

Note: The RenameColumns function is not a Delegable function, so please remove the RenameColumns function from your ForAll formula, otherwise, it would cause a Delegation issue.

 

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (7,431)