0

I was reading some doc related to salesforce interview. There I found this question that: "How to update the record using After Trigger context?" And the ans for this question is: "Not possible. You will get error like “Record is Read only”." May I know way. Anyone can explain me with a example. My thought on this is if we take a example that update contact when related account get updated. In this we need to update contact only after the account is update. Then how this answer be right out trigger will be after update. If I am wrong pleas guide me.

1

Typically, if you are populating trigger record fields, it is best to use a before trigger, because it does not add transaction cost. However, if you absolutely must populate information to trigger records in an after context, you can re-query for them and act on this new reference, then perform an update. This strategy increases the cost in both DML Statements and SOQL.

  • Yes thing I do know but want to know is "How to update the record using After Trigger context?" And the ans for this question is: "Not possible. You will get error like “Record is Read only” this answer is right or wrong. – Anu Feb 10 '15 at 3:11
0

Actually you can perform DML in trigger from future methods with callout=true. You can call this methods in trigger, but they will be executed after trigger ends, so no error will happen. For example I used it to automatically fill some fields that require ID of record, that can't be received in Before trigger.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.