Posts

Showing posts from April, 2016

Trigger Context Variables

Image
Thought of writing a article around the context variables present in triggers. Before Insert :  Trigger.new would be available as new values are being inserted into the database Trigger.old would not be available as fresh records are being inserted into the database Trigger.newMap would not be available as the record id's are not generated in before insert event Trigger.oldMap would not be available as the record id's are not generated in before insert event After Insert :  Trigger.new would be available as new values are being inserted into the database Trigger.old would not be available as fresh records are being inserted into the database Trigger.newMap would be available as the record id's are generated in after insert event Trigger.oldMap would not be available as fresh records are being inserted into the database Before Update :  Trigger.new would be available containing the updated values Trigger.old would be available containing the old val

Webservice callout from Scheduled Apex

Making webservice callout from Schedulable classes Ever faced the error " System.CalloutException: Callout from scheduled Apex not supported. " This is the error you get when you are making a webservice callout from a class which is implementing Database.Schedulable interface. Salesforce does not allow you to make callouts from Schedulable classes. So I had this requirement where I needed to schedule a piece of code which was making a callout to external websrvice. This is my schedulable class : public class ExampleScheduler implements Schedulable{        public void execute(SchedulableContext SC) {       ExampleHelper.makeWebserviceCallout();    } } This is the class which contains webservice callout : public class ExampleHelper{ public static void makeWebserviceCallout(){ HttpRequest req = new HttpRequest(); req.setEndpoint('http://www.yahoo.com'); req.setMethod('GET'); String username = 'myname'; String password =

Update Converted Leads - Spring 16

With Spring 16 release, now you can update the converted leads. You need to do some user-specific and profile based settings and you are good to go. If you are a System Administrator, then you can even convert the lead which was already converted (seems to be a bug to me). Follow below steps to enable this feature : 1) From Setup, enter User Interface in the Quick Find box, then select User Interface. 2) Select Enable "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners" User Permissions. 3) Save your changes. 4) A4dd the setting to your profiles. From Setup, enter Profiles in the Quick Find box, then select Profiles. Select the profile and then select Set Audit Fields upon Record Creation. 5) Save your changes. If you want to update converted leads through dataloader, then you need to update a setting in Dataloader. Follow below steps to configure your dataloader: 1. In Data Loader, navigate to Settings -> Settings. 2. Upd