I have a set of records I would like to load into my Account object. I'm trying to write a trigger before insert/update to validate the Bus. Id and Account Name already exists in SFDC or not. Because our data is a mess, Bus. ID and Account are not unique.
We should check incoming Bus. Id against Bus. ID in SFDC, if there is a match then we check the Account Name. If both matches then no further actions needed.
If Bus. Id and Account do match then insert record into SFDC.
If Bus. Id match and Account Name doesn't then update the record in SFDC with the incoming Bus. Id.
Can some experts help with the structure of this trigger so I can follow and modify if needed?
This is what I have so far:
trigger Data_Transfer_BI_SFDC on Account (before insert){
List<String> accountupdate = new List<String>();
List<account> accountinsert = new List<account>();
List<String> accountNames = new List<String>();
List<Account> SF_Account = [select id, Service__c, Business_ID__c, name from Account order by Business_ID__c desc];
for (Account a : Trigger.New){
accountNames.add(a.Service__c);
accountNames.add(a.Business_ID__c);
accountNames.add(a.name);
}
}