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 data source you s...
Power Apps
Answered

"The data source you supplied is invalid" yet the patch works

(0) ShareShare
ReportReport
Posted on by 418

I have the below code and it is throwing the error: "The data source you supplied is invalid", however the code works as expected without error.  

 

This wouldn't be problem, however I want different actions based on if there were error patching or not.  This is causing the Errors() funtion to always detect errors, when in reality the patch is going through to the DB just fine.  

 

One thing I found online was to specify the record I want to patch but that seems redundant and the code actually works as is.  

patch.PNG

 

 

If(!IsEmpty(toUpdateSmall),
If(
 IsEmpty(
 Errors(Patch('[dbo].[ForecastData]',toUpdateSmall))
 ),
 Notify("Database toUpdateSmall write succesful", Success);
 
 //put update collection code here 
 ,Notify("Database toUpdateSmall write NOT succesful", Error);

 ForAll(RenameColumns(toUpdateSmall, "ItemId", "ItemId2", "ForecastMonth", "ForecastMonth2", "ForecastYear", "ForecastYear2", "SalespersonId", "SalespersonId2", "CustomerKeyAccountParentId", "CustomerKeyAccountParentId2", "CurrentForecastQty", "CurrentForecastQty2"), Update(datasource_temp2, LookUp(datasource_temp2, SalespersonId2 = SalespersonId && ItemId2 = ItemId && CustomerKeyAccountParentId = CustomerKeyAccountParentId2 && ForecastMonth = ForecastMonth2 && ForecastYear = ForecastYear2), {CurrentForecastQty:CurrentForecastQty2, CustomerKeyAccountParentId:CustomerKeyAccountParentId2, ForecastMonth:ForecastMonth2, ForecastYear:ForecastYear2, ItemId:ItemId2, SalespersonId:SalespersonId2}))

));

 

 

Categories:
  • dyee4614 Profile Picture
    283 on at

    I ran into this same problem.  The issue, as far as I can tell, is that the ForAll can't be nestled that deeply in your formula.  I rewrote a similar formula to you with ForAll at the start and it works fine.

  • SJ-15052312-0 Profile Picture
    418 on at

    Thanks @dyee4614 , However, even if I take the forAll() code out completely, the error still persists.  

     

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @samuelJ ,

    Based on the formula you provided, I think there is something wrong with the Errors function that you mentioned.

     

    The first argument of the Errors function is required to provide a data source rather than a record, the result the Patch function returned is a record value.

     

    I have made a test on my side, please consider modify your formula as below:

    If(!IsEmpty(toUpdateSmall),
    If(
     IsEmpty(
     Errors('[dbo].[ForecastData]', Patch('[dbo].[ForecastData]', toUpdateSmall)) // Modify formula here
     ),
     Notify("Database toUpdateSmall write succesful", Success);
     
     //put update collection code here 
     ,Notify("Database toUpdateSmall write NOT succesful", Error);
    
     ForAll(RenameColumns(toUpdateSmall, "ItemId", "ItemId2", "ForecastMonth", "ForecastMonth2", "ForecastYear", "ForecastYear2", "SalespersonId", "SalespersonId2", "CustomerKeyAccountParentId", "CustomerKeyAccountParentId2", "CurrentForecastQty", "CurrentForecastQty2"), Update(datasource_temp2, LookUp(datasource_temp2, SalespersonId2 = SalespersonId && ItemId2 = ItemId && CustomerKeyAccountParentId = CustomerKeyAccountParentId2 && ForecastMonth = ForecastMonth2 && ForecastYear = ForecastYear2), {CurrentForecastQty:CurrentForecastQty2, CustomerKeyAccountParentId:CustomerKeyAccountParentId2, ForecastMonth:ForecastMonth2, ForecastYear:ForecastYear2, ItemId:ItemId2, SalespersonId:SalespersonId2}))
    
    ));

    or

    If(
     !IsEmpty(toUpdateSmall),
     Patch('[dbo].[ForecastData]', toUpdateSmall);
     If(
     IsEmpty(
     Errors('[dbo].[ForecastData]') // Modify formula here
     ),
     Notify("Database toUpdateSmall write succesful", Success);
     
     //put update collection code here 
     ,Notify("Database toUpdateSmall write NOT succesful", Error);
    
     ForAll(RenameColumns(toUpdateSmall, "ItemId", "ItemId2", "ForecastMonth", "ForecastMonth2", "ForecastYear", "ForecastYear2", "SalespersonId", "SalespersonId2", "CustomerKeyAccountParentId", "CustomerKeyAccountParentId2", "CurrentForecastQty", "CurrentForecastQty2"), Update(datasource_temp2, LookUp(datasource_temp2, SalespersonId2 = SalespersonId && ItemId2 = ItemId && CustomerKeyAccountParentId = CustomerKeyAccountParentId2 && ForecastMonth = ForecastMonth2 && ForecastYear = ForecastYear2), {CurrentForecastQty:CurrentForecastQty2, CustomerKeyAccountParentId:CustomerKeyAccountParentId2, ForecastMonth:ForecastMonth2, ForecastYear:ForecastYear2, ItemId:ItemId2, SalespersonId:SalespersonId2}))
    
    ));

     

    Please consider take a try with above formula, then check if the issue is solved.

     

    Best regards,

  • SJ-15052312-0 Profile Picture
    418 on at

    @v-xida-msft thanks for replying,

     

    The first solution offered provides syntactical errors.  The second solution seems to do the trick though!  One follow up question, will this catch errors if we hit the SQL Server limitation of 100 API calls within 10 seconds?  

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard