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

Detecting duplicates with business rules with date ranges and lookups

Hi!

 

I have a canvas application that has a form with a lookup, start datetime and end datetime. The validation on the app's side works as intended on previous data. However, if two users submit at the same time, the validation does not have enough time to refresh the data and prevent duplicates. A duplicate is defined with lookup GUID and conflicting/overlapping datetime ranges. For example:


Lookup,   Start DateTime,             End DateTime
Lookup1, 09/JUN/2022 08:00:00, 09/JUN/2022 10:00:00  
Lookup1, 09/JUN/2022 09:00:00, 09/JUN/2022 11:00:00  

 

I tried refreshing the data source before the form validation, but that did not prevent duplicates from happening within a very short time frame. I also created an alternate key on Lookup, Start DateTime and End DateTime, which prevented duplicates which are identical, however, the above example goes through when it should not.

 

Business rules seem to not have the capability to replicate the complexity of the validation. Is there anything else I can try? 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
brianpace
Frequent Visitor

The solution to this was inspired by this.

 

Apparently, it is best to query the data source directly, rather than use component outputs and variables. 

I recreated the logic that queries the data source itself in the submit and the duplicate detection was working in real time, save for the miniscule latency between the client and the server.

View solution in original post

2 REPLIES 2
MayankP
Responsive Resident
Responsive Resident

Hi @brianpace ,

 

you can write plug in to validate new record based on your business logic, refer following example article for this..

 

https://docs.microsoft.com/en-us/power-apps/developer/data-platform/tutorial-write-plug-in

brianpace
Frequent Visitor

The solution to this was inspired by this.

 

Apparently, it is best to query the data source directly, rather than use component outputs and variables. 

I recreated the logic that queries the data source itself in the submit and the duplicate detection was working in real time, save for the miniscule latency between the client and the server.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,187)