Sunday 3 July 2016

Salesforce Spring - 16 Administrator Release Questions

1. What object types is Work Orders object associated with?(Choose 2 Answers)

A. Leads
B. Products
C. Cases
D. Service Contracts
E. Milestones

Ans: Cases, Service Contracts

2. What does the Customize Application permission setting allow?

A. To modify custom picklist values.
B. To create article types.
C. To create a new user.
D. To edit contract settings.

Ans: To edit contract settings

3. Which areas are calculated for the Health Check score?(Choose 2 Answers)

A. Session Setting
B. Profiles and Permissions assigned
C. Password Policy
D. Number of users
E. Login attempts

Ans: Session Setting, Password Policy

4. What is true regarding the new Data Loader?

A. It works with all legacy security protocol.
B. It supports Web Server OAuth Authentication for Windows or Mac.
C. It has a new column flagging duplicate files.
D. It has downloadable add-ons published through the AppExchange.

Ans: It supports Web Server OAuth Authentication for Windows or Mac

5. What key user access data is included in login forensics?

A. Who logged in more than the average number of times.
B. Who logged in from a new browser more than once in a day.
C. Who logged in during business hours.
D. Who logged in more than the number set in the profile.

Ans: Who logged in more than the average number of times

Thursday 12 May 2016

Apex batch Auto Monitoring

Many a times you may have been in a situation where Salesforce Apex jobs gives a strong time and you are left with scratching your head due to Apex Job status unavailability. Salesforce Geeks can use an awesome object provided by Salesforce for Apex job Monitoring i.e.- AsyncApexJob . It is a backend object automatically maintained by Salesforce to track past/current Jobs. 

Although Salesforce has provided a great User Interface for same purpose i.e. Setup>Monitor>Jobs>Apex Jobs but sometimes it behaves strangely or you are not able to get proper status for your batch job, so in that case you may use Developer Console/Workbench(My personal favorite) to query AsyncApexJob object and check other details about your Apex Jobs

Lets assume your batch class is names "myBatch" then below SOQL would help you to get data related to your batch job Record

SELECT Id, MethodName, JobItemsProcessed, ApexClassId, ApexClass.Name, CompletedDate, NumberOfErrors, Status, ExtendedStatus, TotalJobItems FROM AsyncApexJob where ApexClass.Name='myBatch' order by CompletedDate Desc Limit 10

Above SOQL will return Status(and other fields) for Batch Job and hence you can identify the exact stage, number of records processed, Reason for failure etc.
********Hopefully it helps your Debugging********
Keep doing Great Work

Tuesday 16 February 2016

Brain Bout for Salesforce Sandbox

What is a sandbox?
Sandbox is a term used for replica copy isolated from the production environment. It is used for development, testing , backup and training purpose for an organisation. These environment are near to exact copy of the schema and data model of the production instance.

Changes done to each of the environment(sandbox or prod) don't affect each other's date state/schema state. Sandbox  Login  URL :  https://test.salesforce.com

NOTE: Sandboxes can only be created from Production Instance and Information about various sandbox is listed in production.

To create a Sandbox:

  1. Goto Setup, click Sandboxes or Data Management |Sandboxes.
  2. Click New Sandbox.
  3. Enter a name and description for the sandbox.
  4. Select the type of sandbox.
  5. Select the data to include in your Partial Copy or Full sandbox.
  6. Click Create.
Depending upon type of sandbox chosen in above steps, Data and various configuration will be copied to the metadata while creating a sandbox. Sometimes the users are not with Full copy sandbox(Dont' worry read along to know about Types of Sandbox and their features) which enables to copy production data along with schema so in that case we can use DataLoader tool or Dataloader.io to import desired data from production into newly created sandbox.

  1. Developer Sandbox : It is the most basic type of sandbox available to most of the customers.These environments include a copy of your production organization’s configuration (metadata) only. This type of sandbox is mostly suitable for Development purpose.
  2. Developer Pro Sandbox : It is a superset of Developer Sandbox i.e Developer pro sandbox consists of all the features associated with Developer sandbox plus it has larger Data Storage which is very helpful in maintaining the unit test record for quality assurance tasks. No production data is copied for this type of sandbox.
  3. Partial Copy Sandbox : It is capable of including a copy of your production organization’s configuration (metadata), and a subset of your production data as defined by a sandbox template. This environment is mainly used for quality assurance tasks, acceptance testing , integration testing etc.
  4. Full Copy Sandbox : It is the most advanced type of sandbox which are mainly intended for UAT, backups, training purpose, performance testing, load testing, and staging. It can be assumed as an exact copy of production environment. It has long refresh time intervals which makes it difficult to use Full sandboxes for development.
Tasks performed by Salesforce while creating or refreshing a Sandbox: 
  • Usernames are modified by appending them with sandbox name to each username.
  • Email fields for each user is also changed in a format like salesforcel1support3=abc.com@example.com

Thursday 11 February 2016

Salesforce Dynamic Visualforce Components

Use Salesforce Dynamic Visualforce Components and Custom Label for predefined String(helpful for displaying Apex Messages etc)

Visualforce is mainly intended for create static pages by using Different namespace tag and dynamically populating the values based on controller binded variables but sometimes Developers need to customize the Pages in such a way to reduce maintainance Development effort and the changes could be carried out in few point and clicks. To adapt this strategy, Salesforce provided -"Dynamic Visualforce Components", Under this approach VF components are dynamically populated in APEX class and then rendered onto the VF page.

Custom Label usage: Developers can use Custom Labels in Apex by using following expressions - System.Label.labelName

VF Page :
1:  <apex:page standardController="Contact" extensions="DynCompExample">  
2:    <apex:dynamicComponent componentValue="{!headerWithDueDateCheck}"/>  
3:    <apex:dynamicComponent componentValue="{!ErrorLabelString}"/>  
4:  </apex:page>  

APEX Class:
1:  public class DynCompExample {  
2:    public DynCompExample(ApexPages.StandardController con) { }  
3:    public Component.Apex.SectionHeader getHeaderWithDueDateCheck() {  
4:      date dueDate = date.newInstance(2016, 2, 8);  
5:      boolean overdue = date.today().daysBetween(dueDate) < 0;  
6:      Component.Apex.SectionHeader sectionHeader = new Component.Apex.SectionHeader();  
7:      if (overdue) {  
8:        sectionHeader.title = 'This Form Was Due On ' + dueDate.format() + '!';  
9:        return sectionHeader;  
10:      } else {  
11:        sectionHeader.title = 'Form Submission';  
12:        return sectionHeader;  
13:      }  
14:    }  
15:       // This method return the String value for the Error Label id   
16:    public Component.Apex.OutputText getErrorLabelString(String labelName){   
17:            Component.Apex.OutputText outputError = new Component.Apex.OutputText();   
18:            outputError.expressions.value = '{!$Label.' + labelName + '}';   
19:            return outputError;   
20:       }   
21:  }  

Note from Salesforce : Dynamic Visualforce components are not intended to be the primary way to create new Visualforce pages in your organization. Existing Visualforce pages shouldn’t be rewritten in a dynamic manner and, for most use cases, standard Visualforce components are acceptable and preferred. You should only use dynamic Visualforce components when the page must adapt itself to user state or actions in ways that can’t be elegantly coded into static markup.

Documentation  Link : https://help.salesforce.com/HTViewHelpDoc?id=cl_about.htm&language=en_US

Wednesday 10 February 2016

Using NewLine in APEX String

String is an awesome DataType provided by Language designers to store any Text Literals(alphabets, numbers, special chars etc) but sometimes Developers need to display Newline Character in the APEX String which can be used on VisualForce Page.

Trick : This can be easily done adding \n for NewLine Character in Apex String and then each \n will be replaced by <br/> in VF page with help of SUBSTITUTE(JSENCODE(Variable), '\\n', '<br/>').

VF Page :
1:  <apex:page controller="Returns">   
2:    <apex:outputLabel value="{!SUBSTITUTE(JSENCODE(choosenText), '\\n', '<br/>')}" escape="false"/ >   
3:   </apex:page>  

Apex Class :
1:  public class Returns{  
2:  public String choosenText{get;set;}  
3:  public Returns(){  
4:  choosenText = 'Hi Salesforce' + '\n' + ' This is a Salesforce Techie Blog.' + '\n' + 'Please share your Feedback';  
5:  }  
6:  }  

Output :
 

Hope this trick is Helpful!!!

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.