Wednesday 12 November 2014

Salesforce Winter '15 Maintenance / Release Exam Notes

        Here is the quick summary of salesforce.com winter 15 release notes,


Community
  1. New Improved Community Manger, Designer Page
  2. Manage communities link will be all communities
  3. Drop down will have Administration Settings and Community Management.
Community Management
  1. Analytical dashboard with trending Capability
  2. Moderate flag post.
  3. Community Content --> Navigational Topics and featured Topics
  4. New dashboards, reports, metrics, dashboards. Map Different dashboard to diff communities.
  5. Manually refresh dashboard.
  6. Community Designer
  7. Replace site.com studio.
  8. Allows self-service communities and configure single sign on portals
  9. Navigate view and branding editor avail.
  10. Preview based on devices how the community will display.
  11. You can still use site.com without using templates.
Self-Service Template
  1. Kokua --> visually rich template, Present knowledge article by using data category. Ability to submit and view support cases.
  2. Koa --> Text based template, View article by text category and optimized for mobile device
  3. Napili --> Powerful template for support communities. User post question, search and view article and contact support agent.
  4. All Communities is build responsive.
Chatter
  1. Unlisted Group --> More privacy and Membership only by invitation, non-members can't ask to join.
  2. This group will not display is list view, feed for non-members. New Manage unlisted group permission can find and access this group.
Forecast
  1. Display overlay splits in the forecast
  2. Display the forecast based on custom opportunity currency field.
  3. Forecast incorporates opportunity split in your custom field.
Outlook
  1. Easily add outlook items to salesforce records.
  2. View the side panel from outlook tasks.
  3. Specify which outlook attachment to add to salesforce records.

Activities
  1. Enable User Control over Task Assignment Notifications --> when this one enable you can go Email me when someone assign me a task.

Service Communities
  1. Allows ask question to followers, group or specific person from feed.
  2. When writing question the related question will be pulled from the salesforce community.
  3. You can choose best answers.
  4. Chatter desktop doesn't support chatter questions.
Knowledge Base Search
  1. You can enable "Highlight relevant article text within search results" in knowledge setting. The searched text will be highlighted.
  2. Default AND/OR Operators in results
  3. Knowledge Search Activity --> Create custom report using this one. You can find the average searched article list.
Salesforce1 Enhancements
  1. It support in windows and blackberry mobile devices.
  2. Single location to access (create, edit, etc.)
  3. Quick start wizard added in salesforce1 setup.
SalesforceA
  1. Access trust salesforce from the below menu,
  2. Home screen | Schedule Maintenance | Trust.salesforce.com
  3. Advance setup search default enabled. It allow enhanced search.

Refernce --> Winter 15 release notes

Friday 17 October 2014

How to avoid Recursive Trigger in Salesforce

To resolve recursive trigger please follow the below steps,

     1. Create a class with the Boolean variable and set this as true to avoid Recursive trigger.
  1. public class RecursiveHandler
  2. {
  3.      public static Boolean isNotRecursive = true;
  4. }

    2. Check the Boolean flag value before process your condition and set the flag value to false at the beginning of your process. Once if you set this false, the recursion will stop.
  1. trigger DuplicateRecordMaker on Account (after insert, after update)
  2. {
  3.     List<Account> accounts = new List<Account>();
  4.    
  5.     if(RecursiveHandler.isNotRecursive)
  6.     {
  7.         RecursiveHandler.isNotRecursive = false;
  8.        
  9.         for(Account currentAccount : Trigger.New)
  10.         {
  11.             Account acc = new Account();
  12.             acc.Name = currentAccount.Name;
  13.             accounts.add(acc);
  14.         }
  15.        
  16.         insert accounts;
  17.     }
  18. }

Hope the above coding will helpful to solve recursive trigger error.

How to avoid maximum trigger depth exceeded exception in Salesforce

As Per Salesforce Governor Limits, Total stack depth for any Apex invocation that recursively fires triggers due to insert, update, or delete statements size is 16.  If you go beyond this limit you will get “Maximum Trigger Depth Exceeded error”.

The below code is one of the example of getting this error,

  1. trigger DuplicateRecordMaker on Account (after insert, after update)
  2. {
  3.     List<Account> accounts = new List<Account>();
  4.     for(Account currentAccount : Trigger.New)
  5.     {
  6.         Account acc = new Account();
  7.         acc.Name = currentAccount.Name;
  8.         accounts.add(acc);
  9.     }
  10.     insert accounts;
  11. }
Reason for getting such error,

            My Trigger concept is whenever account record is created, the same record should be created as duplicate record. After insert a record the above trigger will fire then duplicate record will process after that trigger will call recursively, this cause a Maximum Trigger Depth Exceeded error.

Check out the below link to resolve this error,

 How to avoid Recursive Trigger in Salesforce




Tuesday 7 October 2014

How to Indent / Align / Format Apex Code in Salesforce without using eclipse or any other tools

Most of the Salesforce developer who are not using the Developer Console may not aware how to Indent / align the code. They generally go for external site or applications to intend their code.

If you write Apex class / Apex Trigger / Visualforce page using the normal User Interface, then you code is not auto formatted as well when reading the code is very ridiculous. The coding should always readable to everyone for this you need to indent your code. We can indent the coding using Developer Console.

Here is a simple steps to indent your code using the developer console.

1.    Click “Developer Console” from the Set up menu.



2.    Then Click File à Open à Classes à Select your class that you want to indent.




3.    Select all or just a section of code to indent

4.    Press Shift + TAB




5.    Save


That’s it...! Your code is Indented now...! 

Wednesday 1 October 2014

How to Convert JSON Data to List Class in Salesforce

Problem

  Need to format JSON response and display the response values in PageBlockTable in visualforce page.

JSON String
  1. [
  2.     {
  3.         "label": "Winter '11",
  4.         "url": "/services/data/v20.0",
  5.         "version": "20.0"
  6.     },
  7.     {
  8.         "label": "Spring '11",
  9.         "url": "/services/data/v21.0",
  10.         "version": "21.0"
  11.     },
  12.     {
  13.         "label": "Summer '11",
  14.         "url": "/services/data/v22.0",
  15.         "version": "22.0"
  16.     },
  17.     {
  18.         "label": "Winter '12",
  19.         "url": "/services/data/v23.0",
  20.         "version": "23.0"
  21.     },
  22.     {
  23.         "label": "Spring '12",
  24.         "url": "/services/data/v24.0",
  25.         "version": "24.0"
  26.     },
  27.     {
  28.         "label": "Summer '12",
  29.         "url": "/services/data/v25.0",
  30.         "version": "25.0"
  31.     },
  32.     {
  33.         "label": "Winter '13",
  34.         "url": "/services/data/v26.0",
  35.         "version": "26.0"
  36.     },
  37.     {
  38.         "label": "Spring '13",
  39.         "url": "/services/data/v27.0",
  40.         "version": "27.0"
  41.     },
  42.     {
  43.         "label": "Summer '13",
  44.         "url": "/services/data/v28.0",
  45.         "version": "28.0"
  46.     },
  47.     {
  48.         "label": "Winter '14",
  49.         "url": "/services/data/v29.0",
  50.         "version": "29.0"
  51.     },
  52.     {
  53.         "label": "Spring '14",
  54.         "url": "/services/data/v30.0",
  55.         "version": "30.0"
  56.     },
  57.     {
  58.         "label": "Summer '14",
  59.         "url": "/services/data/v31.0",
  60.         "version": "31.0"
  61.     }
  62. ]
Before creating class, Copy your JSON Response and Paste the response here Json2Apex then create apex. You will get the apex code based on your JSON Response and you can alter it based on your requirement. I have altered the auto generated code for the above json response and the code is,

Apex Class

  1. global class SalesforceVersionInfo
  2. {
  3.     public List<SFInstance> sfInstances{get;set;}
  4.    
  5.     public SalesforceVersionInfo()
  6.     {
  7.         String jsonString = '[{\"label\":\"Winter \'11\",\"url\":\"/services/data/v20.0\",\"version\":\"20.0\"},{\"label\":\"Spring \'11\",\"url\":\"/services/data/v21.0\",\"version\":\"21.0\"},{\"label\":\"Summer \'11\",\"url\":\"/services/data/v22.0\",\"version\":\"22.0\"},{\"label\":\"Winter \'12\",\"url\":\"/services/data/v23.0\",\"version\":\"23.0\"},{\"label\":\"Spring\'12\",\"url\":\"/services/data/v24.0\",\"version\":\"24.0\"},{\"label\":\"Summer \'12\",\"url\":\"/services/data/v25.0\",\"version\":\"25.0\"},{\"label\":\"Winter\'13\",\"url\":\"/services/data/v26.0\",\"version\":\"26.0\"},{\"label\":\"Spring \'13\",\"url\":\"/services/data/v27.0\",\"version\":\"27.0\"},{\"label\":\"Summer\'13\",\"url\":\"/services/data/v28.0\",\"version\":\"28.0\"},{\"label\":\"Winter \'14\",\"url\":\"/services/data/v29.0\",\"version\":\"29.0\"},{\"label\":\"Spring\'14\",\"url\":\"/services/data/v30.0\",\"version\":\"30.0\"},{\"label\":\"Summer \'14\",\"url\":\"/services/data/v31.0\",\"version\":\"31.0\"}]';
  8.         sfInstances = (List<SFInstance>) System.JSON.deserialize(jsonString, List<SFInstance>.class);
  9.         sfInstances.sort();
  10.     }
  11.    
  12.     global class SFInstance implements Comparable
  13.     {
  14.         public String label{get;set;}
  15.         public String url{get;set;}
  16.         public String version{get;set;}
  17.        
  18.         public Integer compareTo(Object ObjToCompare)
  19.         {
  20.             return label.CompareTo(((SFInstance)ObjToCompare).label);
  21.         }
  22.     }
  23.    
  24. }

Visualforce Page

  1. <apex:page controller="SalesforceVersionInfo">
  2. <apex:form >
  3. <apex:pageBlock >
  4. <apex:pageBlockTable value="{!sfInstances}" var="sf">
  5. <apex:column headerValue="Label" value="{!sf.label}"/>
  6. <apex:column headerValue="URL" value="{!sf.url}"/>
  7. <apex:column headerValue="Version" value="{!sf.version}"/>
  8.  </apex:pageBlockTable>
  9. </apex:pageBlock>
  10. </apex:form>
  11. </apex:page>

Result



Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...