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.