January 2019 archive

Record is read-only : Trying to update in after insert trigger

If you have encountered this error while working on Triggers. This is because once you are in an after insert/update trigger and the records are read only in that context as they have been written, but not committed, to the database. Unfortunately your trigger is relying on the ids of the records, which means you …

Continue reading

Permanent link to this article: https://salesforcebuddy.com/2019/01/record-is-read-only-trying-to-update-in-after-insert-trigger/

Salesforce – Spanning Relationships

Each Object in Salesforce is allowed to have upto 15 unique relationships with other objects. Objects can be related to other objects using a relationship field. When objects are related to each other, user can create formulas that reference fields on the other object. For instance: You have a custom object called MyObject1 You have …

Continue reading

Permanent link to this article: https://salesforcebuddy.com/2019/01/salesforce-spanning-relationships/

Apex : Throwing Custom Exceptions

There will be scenarios when you want to throw an exception from your catch block, may be to propagate to the invoking class so it is handled properly. Below is a Custom Exception class which can be used to throw different types of exceptions as needed. public with sharing class CustomExceptions { public class InputDataException …

Continue reading

Permanent link to this article: https://salesforcebuddy.com/2019/01/apex-throwing-custom-exceptions/