Proper placement of Try/Catch blocks

It was recommended by a member to begin putting try/catch blocks in my trigger in order to catch Dml and null pointer exceptions. The issue is when I place them it makes my entire program complain. Right now I’m just putting them where I think they would be helpful, but I really don’t have a good grasp on it. I have a feeling I’m going to get a few down votes for this but my random placement of the blocks isn’t effective..

Trigger to use HTTP callout and update record with the results

I have been trying to integrate Google Shortener API into my salesforce org. I wrote a class to make the call out, but am having difficulty bringing the value back into the record. I have a custom object called “referral_advocate__c” with a field called “Short_URL__c”. Anytime the field “unique_ID__c” has a value, I am wanting to send this value with a static URL to google shortener and then save the response value to “referral_advocate__c.short_URL__c” on the record. This is the class to make the call out:

How to get related list from Trigger.new variable?

trigger TestTrigger on Opportunity (before update){ for(Opportunity o: Trigger.new){ List<Child_Object__c> childObjectList = o.Child_Object__r; System.debug('childObjectList size is '+ childObjectList.size()); } } In the above code the childObjectList size is always printing as zero even though the opportunity object has child objects. Does it mean that I need to fire SOQL query to get the related list? … Read more