Sunday, January 22, 2012

Environment specific variables in SalesForce

If you are developing web-service callouts in development or sandbox and moving them to production, you have to manually change the properties of the out-bound webservices.  For example, you are developing a callout that updates the customer information to an external system when a new customer record is created in SalesForce in Sandbox.  After completing the testing of the callout, you would want to move your apex code to production org.  But, the end point, authentication details of the outbound service will be different than the one in test environments. 

Unfortunately, SalesForce doesn't provide the flexibility of configuration/property files that Java provides.  Luckily SalesForce now provides Custom Label functionality that can be used for this purpose.  
I normally define the endpoints, authentication details as custom labels in sandbox and production orgs.  The advantage is, 
  • the apex classes need not change from sandbox to production.  
  • The test cases run perfectly fine in sandbox and production orgs.  
  • When there is a change in environment specific property value, you need not create a change-set or migrate your code.  
  • Better Apex code development


To create custom labels
Setup->Create->Custom Labels

There are other way of externalizing the properties 

  • Create Properties__C object and store the properties.  The disadvantage of this approach is you are maintaining an object for properties and issuing SOQL queries to retrieve the properties.  
  • Using URLRewrite:  While this solves the purpose like the one mentioned above.  It involves find the parsing various formats of SalesForce's representation of the URLs, i.e.. different urls for internal users, portal users and sites users and you have to understand them
  • Page References:  Using page reference to get the url is limited by developing VF pages and would not address the purpose of this discussion
  • Get Organization ID:  Getting the org. id will also solve the purpose and you can determine based on the org. id which property to use.  But this can lead to issues when you have more than 2 orgs and also multiple outbound web-service environments

Monday, January 2, 2012

UMLet for UML diagrams

Last week, I was searching a free light weight UML software that I can use for doing some UML stuff for a design specification.  I found UMLet to be a cool tool that is easy to develop Activity, Component and Use Case Diagrams.  I can now do design and uml within minutes this tool.  Checkout at www.umlet.com.  


BTW, did I mention how painless it is use in eclipse too!!

Happy New Year 2012

Wishing you a very happy and prosperous 2012 ahead.  I got a chance to lay my hands on one of the best books I've read ever.  The title of the book is "I moved your cheese" by Deepak Malhotra.  This is a must read book if you have already read "Who moved my cheese" by Spencer Johnson.  

Deepak Malhotra brilliantly put forth the need to question the change which Spencer Johnson doesn't cover in the book.  I've loved reading WMMC in the last 9 years and everytime I read, find something new.  Now, I've IMYC an addition to WMMC. 

The best part I liked about the IMYC; it was short, to the point and the author did not dwell into what should the best steps to question change (Maze and Cheese).  Instead he used Max, Zed and Big to come up with their answers by looking at the maze.  Deepak Malhotra asked a series of questions that the reader can answer from their experiences and thoughts.  I would recommend as is a must read for every professional