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
aklkkaklkk 

How to Write a trigger on Account performance like upsert (its means old data found then update else new record Created )?

hi

pelase support me how to slove the problem Trigger like fired Upsert Command (its means old data found the update else not found  new create

how we can do that logic ??


Thanks
Akikk
Nandigam RajeshNandigam Rajesh
Hi,
hope it may helps, change as per your requirement.

Trigger Upsertcommand on Account(after insert, after update){
Account[] acctsList = [SELECT Id, Name, BillingCity
                        FROM Account WHERE BillingCity = 'Bombay'];
for (Account a : acctsList) {
    a.BillingCity = 'Mumbai';
}
Account newAcct = new Account(Name = 'Acme', BillingCity = 'San Francisco');
acctsList.add(newAcct);
try {
    upsert acctsList;
} catch (DmlException e) {
    // Process exception here
}
}

Regards
Rajesh
aklkkaklkk
Hey Rajesh

its not working like upsert do you know about Upsert ?? if you kwno that about upsert then slove problem becasue code is not working.

Thanks