You need to sign in to do that
Don't have an account?

Urgent requirement please help..
The requirement is when I insert records,if they meets the criteria records should gets updated else they should be inserted.
I have written a trigger on before insert event but what is happening is I am able to update the records but I am not able to stop them from being inserted. Means with update they are also getting inserted. But on update criteria I only want to update the records that are already in Salesforce.
All Answers
myInsertedRecord.addError('The existing record was updated.');
Your Question is :
1. The requirement is when I insert records,if they meets the criteria records should gets updated else they should be inserted.
I have written a trigger on before insert event but what is happening is I am able to update the records but I am not able to stop them from being inserted.
2. Means with update they are also getting inserted. But on update criteria I only want to update the records that are already in Salesforce.
It means you are not updating records , you are creating two record (with old value and new value), can you check code where you are iterating your records and updating its values on the basis of criteria . otherwise can you share you code .
Thanks.
I really appreciate Your support.
But in this way also i have to run a trigger and in trigger if i addError then everything will be roll back. Im not sure about this but i have read somewhere.
if(mapOfOldData.containsKey(checking.ExtId__c) && mapOfOldData.get(checking.ExtId__c).Name == checking.Name ) {
mapOfOldData.get(checking.ExtId__c).city__c = checking.city__c;
updateNewData.add(mapOfOldData.get(checking.ExtId__c));
checking.addError('The original record was updated');
}
I did this but records are not getting updated nor getting inserted.
is it..?
I really appreciate your help..
Thanks a lot.