Hi. Is there a way to detect duplicate record with workflows using onCreate?
The easiest approach I can think of is:
- determine a few key fields to use for checking (use all of them if you wish to check all of them)
- based on those fields construct a query filter using this
- call the compose record search function
If the function returns a result, the record is duplicated.
Basically for my use case a single user will have one record. So I thought of using ownedBy but does beforeCreate has the ownedBy data? For some reason the the workflow doesnt run.
Is Corredor needed for worflows?
The before trigger should have the owner set. The owner flag is set automatically to the invoker (in most cases, the user that created the record) so it might not work for you if the records are created by another entity (such as an administrator account, or any other account that is not the user who should own the record).
You could define a new module field that holds a reference to the user, or use another unique identifier like an email.
It is not (in most cases). Workflows provide an alternative to automation scripts – a nicer GUI for “putting things together”. A workflow can, however, invoke a Corredor automation script which allows you to code complex scenarios that would take too much effort to do within a workflow. If you don’t need it, you can keep it off.
Will try this approch out.
Got it thanks.
Hi @tjerman, I’m interested in how to construct a query ?
if my field I wanna find duplicates for is customer_id
do I need group functionality?
Something in the lines of format("FIELD_GOES_HERE='%s'", record.values.FIELD_GOES_HERE)
(I used the format
function to make it look nicer).
I quickly put together a workflow you can use for reference – duplicate_checker.json · GitHub