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
Jacob W LandisJacob W Landis 

How to write trigger to check if the data is exist do update instead of insert

Hi,

We are using a integration software to import data from eventbrite. since it can only insert record, I have to check whether the data is already in, if so, do update, otherwise insert. Can I do it in before insert? I know before insert can not have DML in it. 
Caleb SidelCaleb Sidel
Check out upsert() https://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_upsert.htm it's a magic little API verb that will do exactly what you want insert or update based on some key (field set to External Id) that you control.
Jacob W LandisJacob W Landis
Since we are using integration tool. There is no way to define using upsert. They can only insert. Can I use upsert in before insert trigger?
Shri RajShri Raj

What is the name of the Integration Software? 

Can they pass the Data through REST methods using GET or POST Methods where you can check if the Data exists and then do a Upsert() functionality

Jacob W LandisJacob W Landis
We are considering using Zapier. We can not use salesforce sync since it is only sysnc standard objects. we are using the custom objects. I don't know whether we can just directly get data from eventbrite. wish somebody here had similar experience.