You need to sign in to do that
Don't have an account?
Carol Matsumura
Trigger to update one field on a case coming from web-to-case
I would like to create a Trigger for new cases being created by web-to-case
My goal is to update the County__c custom field on cases
Only when case RecordTypeName = 'BLNC' and CaseOrigin = 'Web'
Should I use a before or after insert for this?
My goal is to update the County__c custom field on cases
Only when case RecordTypeName = 'BLNC' and CaseOrigin = 'Web'
Should I use a before or after insert for this?
When an object's record is being inserted, if we have to populate some field-values based on some logic on record ITSELF, then we usually prefer before insert.
Let's say, you have chosen after insert instead of before insert, then it is equal to ==> Data is already committed to Database + you are trying to populate values on the same record by updating the record based on the logic (You can only populate its values after insert by updating the record)
==> this causes unnecessary DML i.e, insert + unnessary update.
IF you chose before insert in this scenario => Data is about to be commited + populate necessary values on fields based on desired logic(here you can directly populate values) => Only once DML will happen i.e, insert
Please let me know the requirement, I will try my best to make you understand by code comments