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 / Bug? Mystery blank rec...
Power Apps
Answered

Bug? Mystery blank records

(0) ShareShare
ReportReport
Posted on by 156,570 Most Valuable Professional

Hi all code gurus including

@RandyHayes , @mdevaney , @Pstork1 , @timl 

This has been driving me mad all day (still not solved) - I have posted a lot of code here more for a second set of eyes, but to summarise.

  • We are transitioning from an "old" process to a "new" one over several months and some jobs can be on both lists. The common field is the Work Order. The (very) old list also has some bad practices in field naming and types.
  • As a result, there are three stages of signoff, that are done on the "new" form and are then patched to the equivalent item on the "old" list.
  • One piece of logic however if these is something in the field on the "old" list, do not over-write it. The new list items also have a field called P2Defect which is marked as "Yes" if there is something in the "Old" list matching.

So to the issue - the patch actually works perfectly, but on each occasion creates two (always 2) blank records in the "new" list

I have cross-tested it is picking up the correct ID and Work Order (which it is), but these blank records just keep growing (a lot of field staff with iPads closing jobs - also does it on PCs).

First piece of code on the gallery OnSelect choosing the record (I have gone back to some "long" code in a bit of desperation)

UpdateContext(
 {
 var_P2Rec: 
 If(
 ThisItem.P2Defect = "Yes",
 LookUp(
 P2List,
 'Work Order' = gblWO
 ),
 Blank()
 )
 }
);
UpdateContext(
 {
 var_ID: 
 If(
 !IsBlank(var_P2Rec._ID),
 var_P2Rec._ID,
 0
 )
 }
)

works perfectly and picks up the correct record and ID from the "old" list (or sets the variable to zero).
This then runs on the Form OnSuccess - no errors, patches the correct record but gives two bonus blank ones on the "new" list (which the form is based on). I have structured it so it is hopefully easier to browse through.

UpdateContext({varSubmit: Self.LastSubmit});
If(
 var_ID > 0,
 With(
 {
 wCompBy: 
 If(
 !IsBlank(var_P2Rec.'Completed By'.Value),
 var_P2Rec.'Completed By'.Value,
 If(
 Len(varSubmit.CompletedBy) > 0,
 LookUp(
 colCrew,
 FullName = varSubmit.CompletedBy
 ).Employee,
 Blank()
 )
 ),
 wCompDate: 
 If(
 Value(var_P2Rec.'Date Completed') > 0,
 var_P2Rec.'Date Completed',
 If(
 Value(varSubmit.DateCompleted) > 0,
 varSubmit.DateCompleted,
 Blank()
 )
 ),
 wSignBy: 
 If(
 !IsBlank(var_P2Rec.'Signoff By'.Value),
 var_P2Rec.'Signoff By'.Value,
 If(
 Len(varSubmit.SignoffBy) > 0,
 LookUp(
 colCrew,
 FullName = varSubmit.SignoffBy
 ).Employee,
 Blank()
 )
 ),
 wSignDate: 
 If(
 Value(var_P2Rec.'Signoff Date') > 0,
 var_P2Rec.'Signoff Date',
 If(
 Value(varSubmit.SignoffDate) > 0,
 varSubmit.SignoffDate,
 Blank()
 )
 ),
 wFFABy: 
 If(
 !IsBlank(var_P2Rec.'FFA Close'.Value),
 var_P2Rec.'FFA Close'.Value,
 If(
 Len(varSubmit.FFASignoff) > 0,
 LookUp(
 colCrew,
 FullName = varSubmit.FFASignoff
 ).Employee,
 Blank()
 )
 ),
 wFFADate: 
 If(
 Value(var_P2Rec.'FFA Date') > 0,
 var_P2Rec.'FFA Date',
 If(
 Value(varSubmit.FFADate) > 0,
 varSubmit.FFADate,
 Blank()
 )
 )
 },
 Patch(
 P2List,
 {_ID: var_ID},
 {
 'Completed By': {Value: wCompBy},
 'Date Completed': wCompDate,
 'Signoff By': {Value: wSignBy},
 'Signoff Date': wSignDate,
 'FFA Close': {Value: wFFABy},
 'FFA Date': wFFADate
 }
 )
 )
)

Any thoughts would be most welcome.

 

Categories:
  • timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    Hi @WarrenBelz 

    I guess like you, I can't see why this formula with a single Patch would create two additional blank records.

    If you've not done so, could you run your app through a Monitor session? By working through the trace, you could maybe identify the trigger that's causing the two blank rows.

    Also, could be possible that there's some other process that might be creating the duplicate records? For example, a Flow somewhere on P2List with a 'record added' trigger?

  • WarrenBelz Profile Picture
    156,570 Most Valuable Professional on at

    Hi @timl ,

    I will try the monitor, but to add to the mystery (as well as no extra records being created when nothing is in OnSuccess - so there is nothing other than the code producing the records), if I simply update the record content variable OnSuccess and then present the user with a button and run the same code, no extra records are created and the code again runs perfectly.

    There is nothing triggered off P2List automatically (which would trigger with the button anyway).

    I have surrendered to option B (user button) presently, but will continue to try to see what is happening here. 

    Thank you for taking the time to look at this - I appreciate it.

     

  • Verified answer
    WarrenBelz Profile Picture
    156,570 Most Valuable Professional on at

    Update - as usual with these things the culprit is below the surface and not where one looks. I had a couple of controls (combo boxes) which were actually triggering OnChange Patch code when a form was simply opened in View Mode. They were supposed to update the list item (which in normal circumstances they did fine), but were lacking the parameter of the relevant record - so they simply created new ones . . . not sure if this is a bug, but OnChange should not trigger on form opening.

  • timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    Thanks for the update @WarrenBelz - glad you found the cause.

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