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 / Preventing duplicate e...
Power Apps
Unanswered

Preventing duplicate entry creation via Patch?

(0) ShareShare
ReportReport
Posted on by 732

I have a couple of attendance apps for different reasons that all write to the same table called Daily Activity Attendance. Up until this point my technique of If(Blank(LookUp())) record is true patch existing or create new has worked pretty reliably. I have a new app that I made in last few weeks that has been having duplication issues. I am wondering if anyone can tell me what I am missing?

 

I have a gallery of students. In that gallery is a Icon that for OnSelect says:

If(
 IsBlank(
 LookUp(
 '[dbo].[Today Activity Attendance Unfiltered]',
 DailyAttUID = 'User ID' && AttendanceDate_x0020_String = TodayVar
 )
 ),
 Patch(
 '[dbo].[Daily Activity Attendance]',
 Defaults('[dbo].[Daily Activity Attendance]'),
 {
 DailyAttUID: 'User ID',
 AttendanceDate: Today(),
 AfterBusRoom: 1,
 AfterBusRouteID: LookUp(
 LocalRoutes,
 Bus_x0020_Route = BusFinal,
 BusRouteID
 ),
 AfterStopID: LookUp(
 LocalStops,
 Stop_x0020_Name = StopFinal && Time = "Afternoon",
 StopID
 ),
 SignoutTime: Text(
 Now(),
 "[$-en-US]hh:mm:ss"
 )
 }
 ),
 Patch(
 '[dbo].[Daily Activity Attendance]',
 LookUp(
 '[dbo].[Daily Activity Attendance]',
 DailyAttUID = 'User ID' && AttendanceDate_x0020_String = TodayVar
 ),
 {
 AfterBusRoom: 1,
 AfterBusRouteID: LookUp(
 LocalRoutes,
 Bus_x0020_Route = BusFinal,
 BusRouteID
 ),
 AfterStopID: LookUp(
 LocalStops,
 Stop_x0020_Name = StopFinal && Time = "Afternoon",
 StopID
 ),
 SignoutTime: Text(
 Now(),
 "[$-en-US]hh:mm:ss"
 )
 }
 )
)

The table at the top is a SQL View that is:

SELECT DailyAttUID, [AttendanceDate String]
FROM dbo.[Daily Activity Attendance] AS att
WHERE (AttendanceDate = CAST(DATEADD(hour, - 8, GETDATE()) AS DATE))

It seems like if the user taps the button fast enough it creates multiple records. Within 10 seconds it seems. I am wondering if it is running command in parallel? If so can I stop it or maybe deal with it?

Categories:
I have the same question (0)
  • v-monli-msft Profile Picture
    Microsoft Employee on at

    Hi @BrianHFASPS ,

     

    Did you mean that when IsBlank function returns true, then you select the button multiple times, it will create multiple duplicated new records? If so, this is expected behavior I think. Since every clicking returns ture, then everytime it will runs the first part which is  Patch('[dbo].[Daily Activity Attendance]',Defaults('[dbo].[Daily Activity Attendance]'),.... This will always creates a new record with the data you have filled in the related columns.

     

    Or did I misunderstand anything?

     

    Regards,

    Mona

     

    Regards,

    Mona 

  • BrianHFASPS Profile Picture
    732 on at

    The way the code should work (I think) is first time the action is run it creates a new record. Then once that record is created any subsequent attempts will simply modify existing records. I have done this in many of my apps where it does a lookup to see if record exists and either creates or modifies. In this instance however it seems I am getting some kind of race condition where user can click icon fast enough that actions are going in parallel almost. I haven't had this issue before though so I am trying to understand what I did wrong maybe this time.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard