function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
frederic baudaxfrederic baudax 

Trigger - upsert-like function for new accounts

We're going to build an automatic dump of customers into SFDC on a nightly base, in order to avoid duplicates we're using an external Id.

 

We also want to avoid creating dupes if the external Id hasn't been added in SFDC but still update that accounts.

 

The idea is the following

1) check if external Id exist in SFDC, if match proceed to update

if not =>

2) check if "another unique id" exist in SFDC, if match add the SF id and proceed to update

if not =>

3) check if the "some fields" match an account in SFDC, if match add the SF id and proceed to update

if not =>

4) check if the "some other fields" match an account in SFDC, if match flag  and insert

if not =>

5) insert

 

Obviously it needs to be bulk free. I have made a few attemps to build a trigger based on Maps and sets but no success. Seems a lot more complex than what i thought in first instance.

 

Can anyone help me with a basic sample or guidlines to achieve something like this.

 

Thanks in advance!