Posts tagged ‘@knthornt’

October 7, 2011

You know that I could use somebody…

Yesterday, Boston hosted the largest Salesforce user group ever! There were 426 registrants, and we packed the ballroom at the Seaport Hotel. In attendance, we had everyone from new Salesforce prospects, to C-level executives at some of the leading companies in the area. We had attendees coming from Rhode Island, Vermont, Maine, North Carolina and even a surprise guest all the way from Salesforce HQ in San Francisco.

Boston User Group - credit to @knthornt

I’ve written about the user groups in the past, (and that post wasn’t a huge success). But I’m going to try it again, because I feel so strongly about what these groups offer to those who attend the meetings.

Of course there is the free breakfast and the potential to get some swag, but that’s not why I go. It’s that chance to network, to share some of the things I know, and to see innovative things that others are doing with the platform. I go to see the vendors, and explore new ways to expand functionality. I guess you could say that I go to teach, and to learn.

With over 140 groups worldwide, there is no reason why you shouldn’t be attending. And yes, not every group is as large or as organized as Boston. But it got that way because there are passionate people attending our meetings. What’s to stop you from doing the same?

Advertisements
May 13, 2011

Trigger Happy!

I talk a lot about the ‘auto-magic’ in salesforce.com, but we all know it has it’s limitations. One of the things that I always wished could be done with button-clicking was to create a new record when conditions on another record were met (ya know, using some workflow powers). I really just considered myself out of luck.

That is until I started dabbling in the developer world. And while I consider myself knowing just enough to causing catastrophic damage, a business case presented itself in which trying out my new skills was the perfect fit. In short, the team wanted a record auto-created every time a specific type of event was created.

Here it is, my debut into triggers (excluding my copy-edit-paste of one from MichaelForce):

trigger createPDtask on Event (after insert) {     
List<Support_Request__c> sr = new List<Support_Request__c>();
    for (Event newEvent: Trigger.New)
         if (newEvent.Type__c == '1. Meeting - Initial'){
                 sr.add (new Support_Request__c(
                     Name = 'New PD',
                     Task_Type__c = 'PD',
                     SFDC_Record_ID__c = newEvent.Id,
                     Rep__c = newEvent.OwnerId,
                     Event_Date__c = newEvent.ActivityDate));   
         }
   insert sr;
 }

So there it is. Short & fairly simple, but a HUGE¬†productivity¬†win. Plus, now everyone thinks I’m magic! And if you want a deeper dive explanation on the anatomy of this trigger, read my post on the Teach Me Salesforce blog!

UPDATED!! Here is my test class (Huge thanks to Kyle for help with the System.assertEquals bit:

@isTest private class createPDtask_Test { 
   private static testmethod void testTriggerForEvent(){         
 Event e = new Event();   
               
 //Required Fields         
 e.Subject = 'testSubject';         
 e.IM_Type__c = '1. Meeting - Initial';         
 e.Product_Interest__c = 'None';         
 e.StartDateTime = DateTime.NOW();         
 e.EndDateTime = DateTime.NOW()+1;                  


 //Insert the Record         
 insert e;                  


 //Query for Inserted SR         
 List<Support_Request__c> testRequests = [SELECT id FROM Support_Request__c             
 WHERE SFDC_Record_ID__c = :e.Id];                      


 //We expect one record to be created         
 System.assertEquals (1, testRequests.size());        
 } 
}
%d bloggers like this: