cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
calvares
Continued Contributor
Continued Contributor

Patch function has stopped working properly

My canvas app has a registration form with a SharePoint list (LaserRegistration) as a data source. 

On the OnSelect of the submit button there is this:

UpdateContext({LastLaser: Last(LaserRegistration)})

Then the OnSuccess of the form there is a patch:

Patch(
LaserRegistration,
Last(LaserRegistration),
{
Title: "LAS - " & LastLaser.ID,
'Laser ID': "LAS - " & LastLaser.ID,
LaserStatus: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Value: "NEW"
}
}
);

This has been working fine for over a year now. I logged into the app in the studio around the 20th April and since then, the Title and Laser ID have stopped patching back with LastLaser.ID. 

I can see the patch is working because LaserStatus updates. The context variable LastLaser.ID is displaying correctly after submit.

 

I'm on PowerApps release 3.21043.23. I've tried changing to an earlier authoring version and a version of the app pre-20th April but the issue remains on testing. I've not changed anything in app otherwise. Is there anything else I could try?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@calvares 

You are using a Last function in your formula...this is not delegable.  Once you hit the record limit, from that point forward you will only get the last record of 2000 records.

 

Consider the following changes to your formula.

With({_last: First(Sort(LaserRegistration, ID, Descending))},
    UpdateIf(
        LaserRegistration,
        ID=_last.ID,
        {
          Title: "LAS - " & Text(_last.ID),
          'Laser ID': "LAS - " & Text(_last.ID),
          LaserStatus: {Value: "NEW"}
        }
    )
);
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

7 REPLIES 7
Pstork1
Dual Super User III
Dual Super User III

Check your Office 365 admin center > Services Health.  Power Apps is currently experiencing an outage.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
RandyHayes
Super User III
Super User III

@calvares 

Unless you are dealing with the outage right now, my other question would be, how many records do you now have in your list and what is your record limit set to in your advanced settings?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
calvares
Continued Contributor
Continued Contributor

The issue started at 1020 items and the record limit is 2000.

I didn't think that this limit affected data submitted back as well as queries?

RandyHayes
Super User III
Super User III

@calvares 

You are using a Last function in your formula...this is not delegable.  Once you hit the record limit, from that point forward you will only get the last record of 2000 records.

 

Consider the following changes to your formula.

With({_last: First(Sort(LaserRegistration, ID, Descending))},
    UpdateIf(
        LaserRegistration,
        ID=_last.ID,
        {
          Title: "LAS - " & Text(_last.ID),
          'Laser ID': "LAS - " & Text(_last.ID),
          LaserStatus: {Value: "NEW"}
        }
    )
);
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

calvares
Continued Contributor
Continued Contributor

I see, it's the Last function. I'll try this thanks.

 

So can it start failing well before it reaches 2000 records as it has here?

RandyHayes
Super User III
Super User III

@calvares 

The fact that you have an issue before hitting the limit is a bit unusual.  Not sure what the implication there is.

But, the new formula will sort the list in reverse order (which is delegable) and then take the First record in that result list.  From there the rest of the formula will do its thing.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
calvares
Continued Contributor
Continued Contributor

Thanks @RandyHayes your formula has resolved the issue.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (26,035)