Wednesday 24 July 2013

Cloud Trivia#5:

It is a free, community driven Q&A for Salesforce administrators, implementation experts, developers and anybody in-between.

This site is currently in public beta. Anyone may participate. The purpose of the public beta is to:
  • record metrics about questions, answers, and traffic
  • grow the Q&A community around the topic
  • determine if the site attracts a viable audience

It synthesizes the aspects of Wikis, Blogs, Forums, and Digg/Reddit in a way.

This site is that tiny asterisk in the middle, shown in above picture. Name this site.

Cloud Trivia#4: Which two new formula functions have been added in Winter '13 release ?


Cloud Trivia#3: Name all the Visualforce chart types available in Salesforce

With the release of Winter '13,

Four new Visualforce chart types are available in addition to the existing Three chart types.

You have to name all the 3 OLD chart types and all the 4 NEW chart types in Salesforce.

Cloud Trivia#2: Name a performance management application which uses the concept of Gamification?

Gamification is the Concept of use of Game Elements and Game Design techniques in non-Game contexts.

Name a performance management application (that uses Gamification ) that :

  • helps end users manage their goals, track their progress, and

  • compare themselves to their peers through a scorecard.

  • It helps managers see who is performing and who needs help - all in real time.

Cloud Trivia#1: Name this Apex component

This apex component allows users to quickly change field values on a record's detail page, saving the user from having to access the record's edit page first.

Salesforce Touch Platform – Mobile Development Guide

This place contains everything you need to learn to develop mobile apps in the cloud. Browse to this place and get started today!

Formatting the TODAY Date in Email Template

If you have ever inserted the current date for example in an email template you know it formats at MM/DD/YYYY (e.g., 05/10/2011). 


If you want it to display as 10 May , 2011 or some other formatting, the trick is to have your administrator create a custom formula field on the USER record that re-formats this date and then you can use this field (Send User Field) in your template.

This can be achieved by setting up on the User object a custom formula field that will return (as a text) the desired date format.

Once this field has been set up, you can use it as a merge field in your email templates, instead of the standard {!Today} merge field.

The formula to be used in the custom formula field is the following:


TEXT(DAY(TODAY()))&" "&CASE(MONTH(TODAY()),1,"January",2,"February",3,"March",4,"April",5,"May",6,"June",7,"July",8,"August",9,"September",10,"October",11,"November","December")&" "&TEXT(YEAR(TODAY()))

Custom Settings Overview

-Custom settings are similar to custom objects and enable application developers to create custom sets of data, as well as create and associate custom data for an organization, profile, or specific user.
-All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. This data can then be used by formula fields, validation rules, Apex, and the SOAP API.



There are two types of custom settings:

  List Custom Settings
  -A type of custom setting that provides a reusable set of static data that can be accessed across your organization.
  - If you use a particular set of data frequently within your application, putting that data in a list custom setting streamlines access to it.
  -Data in list settings does not vary with profile or user, but is available organization-wide.
  - Examples of list data include two-letter state abbreviations, international dialing prefixes, and catalog numbers for products. Because the data is cached, access is low-cost and efficient: you don't have to use SOQL queries that count against your governor limits.
  Hierarchy Custom Settings
  -A type of custom setting that uses a built-in hierarchical logic that lets you “personalize” settings for specific profiles or users.
  -The hierarchy logic checks the organization, profile, and user settings for the current user and returns the most specific, or “lowest,” value.
  -In the hierarchy, settings for an organization are overridden by profile settings, which, in turn, are overridden by user settings.

The following examples illustrate how you can use custom settings:
  -A shipping application requires users to fill in the country codes for international deliveries. By creating a list setting of all country codes, users have quick access to this data without needing to query the database.
  -An application calculates and tracks compensation for its sales reps, but commission percentages are based on seniority.
  -By creating a hierarchy setting, the administrator can associate a different commission percentage for each profile in the sales organization.
  -Within the application, one formula field can then be used to correctly calculate compensation for all users; the personalized settings at the profile level inserts the correct commission percentage.
  -An application displays a map of account locations, the best route to take, and traffic conditions. This information is useful for sales reps, but account executives only want to see account locations.
  -By creating a hierarchy setting with custom checkbox fields for route and traffic, you can enable this data for just the “Sales Rep” profile.

Useful References:

Understanding Force.com Platform Internals Helps You Build Better Apps

Today when I was going through my Outlook, I saw an email from one of my colleagues. That email was talking about a blog on how understanding Force.com Platform Internals helps you build better apps.
I went through that blog and find it quite interesting to share it on the Hub.

The blog starts like this: When you have a good understanding of how something works, you greatly increase the likelihood that you’ll have a better experience using that something.



Consolidating the related resources at one place:


Displaying reports and dashboards on a visualforce page

Displaying reports and dashboards on a visualforce page is very quick and easy to implement.

To display a report or dashboard the iframe component is used. Copy and paste the code below into your visualforce, entering the id of your report or dashboard. You may also wish to adjust the height of the iframe.



Integrating Salesforce.com Applications and SAP

With the Big Rule#1 coming in for Legal Salesforce instance, I was wondering how to get "Overview of SAP/Force.com Integration Technologies".
Suddenly I came across a document which could be useful in this context.

This is a useful PDF Guide that will show you how to integrate Salesforce CRM and SAP through the Force.com Platform.

Tabbed Visualforce Page

A tabbed visualforce page can prove useful if you want to create a page that displays a large amount of data in a tidy format, for example, if your App contained a lot of tabs and you wanted to group some into sub tabs.

This post will show how to create a tabbed page that displays list views for Accounts and Opportunities in the newer Salesforce tab skin.


To know in detail, please visit this link: Tabbed Visualforce Page | Salesforce Tutorials

Protecting Force.com Custom Sharing Code

The Force.com platform includes a large set of powerful tools for configuring users’ access to application data.
  • Organization-wide default sharing models
  • Role hierarchy
  • Public groups
  • Ownership- and criteria-based sharing rules
  • The Salesforce Territory Management feature

These platform features can handle almost any security use case you have, but sometimes your requirements are so unique and specific that you have to write custom code to manage them. Unfortunately, when you do this, you have to play a little defense to protect the shares that you write against some of the automatic sharing behavior of the platform. In this blog post, we’ll discuss some advanced sharing features and coding strategies you can use to keep Force.com from messing with your sharing code.


Related Resources


Apex script statements reduction: "How To write apex code that adds less to script statement governor limit ?"

While I was working on Subscription Sorting for December Release 2012, I came across a requirement when I had to fetch more than 1000 records from the Web Service.
Our apex class was supporting around 500 records to be fetched. Getting results>500 was causing an error like: "Too many script statement 200001".

I search on some forums, discussion boards, blog etc and finally  find the reason behind and it was pretty interesting to know that there are workarounds available to tackle this.

So, let us go step by step.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

What is an Apex script statement ?


Its any coded instruction that performs an action. In Apex, statements must end with a semicolon and can be one of the following types:
  • Assignment, such as assigning a value to a variable
  • Conditional (if-else)
  • Loops
  • Do-while
  • While
  • For
  • Locking
  • Data Manipulation Language (DML)
  • Transaction Control
  • Method Invoking
  • Exception Handling
for ex.

What gets counted into Apex script statements ?

I have seen many developers making there apex code ugly just to reduce the number of script statements. I respect this thought, as the end goal is to never cross or add significantly to the apex script statements governor limits. In this effort we sometimes do some reductions that are not really counted into script limits. Following are the code snippets and there equivalents that  use same script statements.

THE UGLY IF ELSE BLOCK

// UGLY Script statement
if (true) System.debug('true');
else System.debug('false');

// Equivalent more readable form, both on execution count 1 script statement
if (true) {
     System.debug('true');
else {
     System.debug('false');
}

THE UGLY VARIABLE DECLARATION.

// UGLY declaration of variables
String str1, str2, str3, str4;
// You might think this will count as 1 script statement, its actually "4".
// Because short hand notation is expanded by many languages. So why do this 

So there are few examples where developers can make there life really easy by writing well expanded and indented code.
The thumb rule of apex is Any thing ending with semi-colon is script statement !”,  so here are the quick notes about what’s not a script statement.

  • Any Apex Standard class methods that you invoke does not matters how complex its internally is. It will never get counter to your script limits.
  • Any curly braces { }, newlines and tabs you add are not script statements. Add them to make your code more readable.
  • Any conditional evaluations/expressions for ex. if () are not counted into script statement.

How to reduce Apex Script Statements ?

There are ways to do so. Following are some code snippets that explain this:

    Collections like Map, Set, List
     All these collections offer a shorthand way to initialize the collection at the time of declaration. This is really helpful if you are going to insert simple data, as that statement is just counted as 1 script statement. Check the                  example below.    

// Way 1 to declare and populate a Map
     Map < integer , string > My_Map = new Map < integer, string >();
     My_Map.put(1 'a');
     My_Map.put(2 'b');
     My_Map.put(3 'c');
     //NOTE: It uses 4 script statements, so 1 script statement per key/value pair.

   // Way 2 to declare and populate a Map
     Map < integer, string > My_Map = new Map < integer, string > {1 => 'a'2 => 'b'3 => 'c'};
     //NOTE: It uses 1 script statement, that involves map declaration, instantiation and population.
     // Similarly one can create Set and List in following manner, this type on instantiation is counted as single script statement.
     Set aSet = new Set {'a''b''c'};
     List aList = new List{'a''b''c'};

Combining multiple operations into one.
One can do so by wrapping an assignment statement, inside a condition or another assignment statement OR by calling a required API within a statement context. Though this mostly makes code fairly hard to understand, but reduces the number of script statements. Following code snippet illustrates that

// Creating anonymous Set inside List constructor scope, it counts as 1 script statement
     List aList = new List(new Set{'d''e''f'}) ;
// In the above example the set is created in a simple manner but we can go as complex as we want by invoking other methods.

Though there can be many more examples to above, but I really don’t appreciate doing this, as it really makes code hard to read.  A few more script statements are acceptable here.

Who should care about reducing apex script statement ?


If you are writing simple customization for force.com/sfdc, then you really don’t need to bother about this. But this requires some consideration when you are a developer in following scenarios:
  • You are developing a library or utility Apex API that’s will be used by many others. Here any reduction in script statement is pretty useful, for ex. if you are writing something to parse a complex Xml structure, you might quickly add a lot to script statement in such API’s and this will leave less room for client code.
  • Developing for a large force.com customization or project. Here chances are there that many developers will be contributing to same Apex code flow, so keeping room for others will make you scale well.

References