Thursday, May 29, 2014

How to enable Salesforce1

Salesforce1 is the next big thing that salesforce has launched. It brings the mobile development to a whole new level. Now a developer can use his/her force.com skills to make mobile compatible application on force.com platform itself. They do not have to learn new technology if they want to develop an application for salesforce mobile version.

Here are steps to enable Salesforce1 in your organisation :

1. If this is a new organisation then no need to do from Step 1 to Step 3.
     Go to Setup > Administration Setup > Mobile Administration > Salesforce1 > Settings
2. Check Enable the Salesforce1 mobile browser app.
3. Save
4. Go to Setup > Administration Setup > Mobile Administration > Salesforce Classic > Settings
5. Check Enable Salesforce Classic Lite.
6. Save
7.Go to Administration Setup > Mobile Administration > Mobile Navigation
8. Choose all that Tabs that you need to display and click save.

Note: The first tab will be the landing tab for Salesforce1.

That is all and now Salesforce1 is enabled.

Tuesday, May 27, 2014

How to use Visualforce Charting Salesforce


From Winter 13 the introduction of visualforce charting has changed the games, as we can achieve that visual feeling in the page that makes it more attractive.
"Visualforce
 charting gives you an easy way to create customized business charts, based on data sets you create directly from SOQL queries, or by building the data set in your own Apexcode. By combining and configuring individual data series, you can compose charts that display your data in ways meaningful to your organization."

Lists considerations and known limitations for Visualforce Charting.
  • Visualforce charts only render in browsers which support scalable vector graphics (SVG). For more information, see WC3 SVG Working Group.
  • Visualforce charting uses JavaScript to draw the charts. Visualforce charts won’t display in pages rendered as PDFs.
  • Email clients do not usually support JavaScript execution in messages. Don’t use Visualforce charting in email messages or email templates.
  • Visualforce charting sends errors and messages to the JavaScript console. Keep a JavaScript debugging tool, such as Firebug, active during development.
  • Dynamic (Apex-generated) charting components are not supported at this time.


Page: Controller:


Tuesday, May 20, 2014

How to get all fields of Object using Schema.DescribeSObjectResult

We use many fields and values to populate the data in the objects, but some time we face a problem where we need to use describe the type of fields. Consider that we need all the fields of an object to be populated and if that object has more that 100 fields then it will take a lot of time to do so, we have to use data loader. But by using Apex we can do this in developer console.

Example:

Wednesday, May 14, 2014

How to initialize SObject

SObjects are very use full in managed packages and dynamic code scenarios. But when it comes to use it we are in bit of a confusion. There are many ways we can initialize SObject as :
  1. Direct initialize - sobjects can be directly initialize to a existing Standard or Custom object.
  2. Dynamic initialize - we can decide object type by passing string to  Schema.SObjectType.
Examples: 

Different ways to achieve "Pagination" in Salesforce.

When it comes to pagination in visual force page we relay on the most widely used approach that is :
StandardSetController. By far it is the best thing that we can use but some times it might happen that we need to used some other variables with the data records in a table and at that time we might not be able to use "StandardSetController". Also it might happen that binding and rebinding of data list back and forth from "getRecords()" is time taken and we need a more direct approach.

We can do this by three ways:-
1. StandardSetController with binding and rebinding using wrapper class.
2. Using offset for displaying just records not using wrapper class.
3. Using List.size() to determine page number and get records from index.