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.
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
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.