Tuesday, February 09, 2016

Salesforce Sandbox Templates and Post Refresh Scripts

With Salesforce Spring 16 release,

we are getting a nice hook to tag an Apex Class to run every time a sandbox gets refreshed..

Typically Salesforce Administrators or Release management teams, goes thru series of steps every time a sandbox is created or refreshed. Salesforce helped them to some extent by bringing in sandbox templates before.. taking it a step further, now they have added the ability to auto run an Apex Class once the sandbox is ready..

This feature is highly useful when we bring in data from production to a sandbox and if

  • we have to scrap or mask certain fields of certain objects 
  • to meet the enterprise data standards policy / be data complaint 
  • protecting customer's privacy data and also 
  • avoiding any automation in non production environments impacting customers.

Until spring 16, we used to run batch jobs to perform tasks like data cleanup, masking, scrapping etc.. from now on we don't need to run the batch job manually. we can include all the logic into an Apex class and

  • either include that Apex class into a sandbox template if its for a partial or full sandbox

  • or directly specify the apex class if its a developer or developer pro sandbox

This feature will be more useful with Partial and Full sandboxes compared to Developer & Developer Pro sandboxes since we don't get any data being copied across with these 2.

With the increased number of sandboxes available for the latest editions of salesforce, this is definitely a time saver for larger development teams using multiple sandboxes and going thru frequent refresh cycles in a project release.

here's the link to the release note page with details..

Spring 16 Sandbox Post Copy Scripts

Monday, January 11, 2016

Salesforce Global / Universal Picklist - Its Finally arrived..

With Spring 16 release, we are getting the long requested Global / Universal picklist feature..

Note it's still in Beta phase and hopefully will become GA in next release..

So How to create a global picklist and use it, here's a quick intro

1. Go to Setup -> Create , you will see the new Picklists menu item

2. Click the Picklists and you will have option to enter a label and api name, just like you create a normal picklist field. Enter a label and name and go to the next screen

3. you will have a large text area to enter the picklist values. Enter the picklist values and save it

4. Now if you go to create a new custom picklist field, you will have an option to either select the values from a global picklist and enter your own values.

5. Give your new picklist a label and name, and choose the global picklist you created before as the source for values and you are done. 

Thursday, January 07, 2016

Salesforce Custom Metadata Types

Its been a while since Salesforce introduced the Custom Metadata Type feature..

if you are wondering how you can make use of this, here's a use case which I recently worked with.

Store all your integration settings in one place, Yes in a single Custom Metadata instead of multiple Custom Settings

Create a custom metadata type called Integration Settings. Include Fields to identify which external system it is, which environment, and the other additional connection details like the endpoint url, username, password, timeout etc..

Create a Utility class method in Apex which takes the external system name we want to connect to as a parameter, and then identifies the current salesforce environment (say production or sandbox using the Organization details ) and returns the connection details for that system in that environment.

With this, we don't need to ever worry about missing integration details during deployments or having incorrect urls in different environments due to sandbox refresh or migration custom settings data between environments or manually creating configuration details.

Salesforce Identify Current Users UI mode theme : Classic or Lightning Experience or Salesforce1 mobile

Now with Spring 16 release, Developers and Admins can easily identify the current user's Salesforce user interface mode or theme - i.e if the running user is using Salesforce Classic UI or the new Lightning Experience in desktop or if the user is in Salesforce1 mobile.

We now have new set of values included in the existing User Context Global variables (both $User in workflows/validations/visualforce/formulas and also to the UserInfo class in Apex)

with this, we can simply call either UserInfo.getUiTheme( ) method or $User.UiTheme variable to identify the running user's UI mode.

here's the list of UI Themes returned by this global variable
  • Theme1—Obsolete Salesforce theme
  • Theme2Salesforce Classic 2005 user interface theme
  • Theme3Salesforce Classic 2010 user interface theme
  • Theme4d—Modern “Lightning Experience” Salesforce theme
  • Theme4tSalesforce1 mobile Salesforce theme
  • PortalDefaultSalesforce Customer Portal theme
  • WebstoreSalesforce AppExchange theme

Reference :
You will find this cool feature documented (buried) deep inside the Spring 16 release notes

Monday, November 30, 2015

Salesforce Process ISCHANGED function not working with compound address fields

I stumbled upon this issue today and raised a case with salesforce and waiting for a response...
just posting it across for others who might face the same issue...

We created a new process on Account to run on both create & update with a simple criteria formula ISCHANGED([Account].BillingAddress) and added an immediate action to the process to do a update a field on the same account record and activated the process.

what's expected is every time we change the billing address on the account, this particular field should get updated with the value from the process.

strangely, thou the process gets saved without any error for using the IsChanged function on the compound address field, when we updated a billing address on an account, nothing happens. The debug logs shows the process being run but the action is not getting fired.

I recreated the same criteria + action using traditional Workflow Rule + Field update and it works perfectly fine. The Workflow rule runs on Account object (both create & update) and uses the same Criteria Formula ISCHANGED([Account].BillingAddress) and updates the same field.

Since support for Compound address field in ISCHANGED function is a recent addition, I believe its not enabled across all functionalities. I will update this post once I hear back from the salesforce support. There is no known issue as well for this. The only option for now is to go with the workaround of using Workflow rule + field update.

After raising a case with salesforce and going thru multiple rounds of discussions, its now considered as a known issue and will be included in one of their future releases (but no ETA yet).

here's the known issue link : https://success.salesforce.com/issues_view?id=a1p30000000ePs6AAE