Tuesday 12 January 2016

Deploying Profiles using Changeset : Salesforce

Many a times Salesforce developers are confused about the point of deploying Salesforce profile using Changeset Deployment. To be Concise, Earlier it was not possible to deploy Profiles using Changeset in Salesforce but due to evolving Salesforce platform, the developers are blessed with this feature in SF Release v30.0. 

Following points would help in clearing some doubts regarding profile deployment through Changeset:

- Adding profiles or permission sets to outbound change sets is designed to allow administrators to migrate permissions for users so they can access new functionality.  Including profiles in change sets is NOT designed to be a tool or method to update profile settings and permissions for functionality already existing in the target environment as per the Change Sets Best Practices documentation.

- Starting in API version 30.0, when deploying a new custom field, the default values for the editable and readable fields in profile field permissions are false. To override the default values, include field permissions for the new field in your profiles.

- A deployment containing a profile and record type, but not the assigned page layout for that record type, removes the existing layout assignment from the profile for that record type. Always include all page layouts for all required record types in the change set. See the Special Behavior in Deployments documentation for more details.

- Profiles or permission sets and field-level security — The contents of a retrieved profile or permission set depend on the other contents of the retrieve request. For example, field-level security for fields included in custom objects are returned at the same time as profiles or permission sets.

Thursday 7 January 2016

Convert Date field to Days of Week in Salesforce

Sometimes the Salesforce requirements are so over-hyped that we do not realize their solution would be so easy. I got a similar requirement in Salesforce where a date field on the case object need to be converted to Days of week for SalesforceCommunication email templates. The formula is really simple to achieve this requirement.

  • Create a Text Formula field on Case object and use the below formula to achieve the goal.

Formula for converting a Date into Days of Week:

CASE( MOD( Date__c - DATE(1900, 1, 7), 7), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3,
"Wednesday", 4, "Thursday", 5, "Friday", 6, "Saturday","Error")

Explanation: This formula is an example of CASE() function in Salesforce. The crux of the formula is that 1/7/1900 is subtracted from the desired date and the result is divided by 7 to get an index of Day of week.