Saturday, 24 August 2013

Aggregate SOQL Functions in SFDC Pros and Cons

"Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch"

I was lately working on some reporting requirement on salesforce which was possible only through visualforce and as soon as i heard the business scenario i was confident enough that my solution will be simplified if i stick to the Aggregate Function in SOQL SFDC.

I knew i had huge data in my org and never thought using Aggregate function will lead me to below error

"Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch"

This error motivated me to blog this article and share some experience on when to make use of these aggregate query and when not in apex .

If you are confident that the data in a object  can exceed 20000(approximate figure) rows i would prefer avoid these and instead prefer using loops and making page read only at-least and writing my own logic to sum and count .

The read only attribute gives the power to exceed the no of rows limit from 50000 to 1000000 and this is huge number and what internally salesforce does is ,it  uses queryMore() call to chunk the data that's rendered on to the visualforce page and hence if we use best practices to manage heap and with winter 14.0 removing the limitations on script statements one can still manage to show data even if the object consists of huge data .

Happy coding !



Saturday, 3 August 2013

From Administrator To Advanced administrator of Salesforce CRM and Force.com Applications



Recently salesforce came with BETA exams for the advanced administrator and this provided me an opportunity to clear this exam free of cost.To know more about what BETA exams are and how they can be useful in getting yourself certified please read the below article 

BETA EXAMS KNOWLEDGE ARTICLE

The aim of this blogpost is  to give an idea of what are the areas candidates must go through to gain this valuable certification.Please dont ask for exam dumps or any other material as these are not ethical and also whats the use of attending an exam just by going through dumps .

Please make a habit of going through study guide and make sure you go through all the videos mentioned in the study guide(All videos are  not free and you may need partner portal access to watch .Ask your organisation if they have one ) .Also search for topics mentioned in  study guide in salesforce help and training portal .

Let me ease some task by providing links to the study guide and help and training portal

LATEST STUDY GUIDE (AS OF SUMMER 13)

HELP AND TRAINING PORTAL

Please make sure to download latest study guide from below link

http://certification.salesforce.com/administrators

The following areas a candidate must concentrate to gain this certification

1)Delegated administration -This topic is very important and huge number of questions come in exams 

2)Security concepts -The sharing model as well as Territory concepts are very vital for this examination.
Go through the guide mentioned below

http://login.salesforce.com/help/doc/en/salesforce_security_impl_guide.pdf

Territories_Implementation_Guide

3)Use of audit logs and debug logs

4)Deployments tools (Change sets ,Force.com IDE and ANT)-The advantages and concentrate mainly on pros and cons of changesets 

5) Forecasting-collaborative forecasting and Customizable and concentrate on reports that can be possible on forecasting

https://na1.salesforce.com/help/doc/en/forecasts.pdf

6)How to customize and maintain products, price books, schedules, and quotes

7)Entitlements and Knowledge service cloud features in service cloud 

8)Reports,Dashboards ,workflows ,Approval process ,formula fields ,need for external Ids,data mangement tools like data loader ,validation rules 

9)Pay special attention to whats PARENTGROUPVAL and PREGROUPVAL Summary formula fields in reporting

10)Content management and data modelling

These are 10 priority items to really dig into while preparing for this exam.

The actual hands on on these topics are really helpful than just trying to go through reading material or videos .You can sign up for free developer org and practice these through workbook and tip sheets available on below link

http://help.salesforce.com/HTViewHelpDoc?id=quicktour_tips.htm&language=en_US

All the best for your preparation and keep following salesforce certification group  in LINKEDIN to recieve more updates ,when these BETA exams are available . 


Saturday, 20 July 2013

Fun With Maps In Apex

Maps are my favorite collection types .The Reason why its very essential to use Maps in apex  classes or triggers is it makes life simple for writing bulkified apex class or trigger .

Read more on Maps in below article from salesforce

http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_maps.htm
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_map.htm

Apex we all know runs on an multitenant  architecture .The resources are shared and hence we have governor limits in apex .The advantages of proper usage of maps will help  to  reduce script statements,No of queries for a single context of class or trigger execution,avoiding query on a single object twice .

As a fresher to salesforce  we are unaware of various techniques that we can employ to reduce the script statements and reduce heap size of collection like Lists,Maps and Sets.

You can read some nice articles in developerforce and get familiar with some of common techniques which developers have discovered to deal with no of script statements and heap size issues

My favorite  recipes are as follows

http://developer.force.com/cookbook/recipe/using-sobject-constructors-to-save-script-statements
http://developer.force.com/cookbook/recipe/initialising-maps-from-queries

If you have been coding in apex from long time you might  have come across common use case that you need to aggregate collection of child records grouped by ParentId.

Something like say i will query on Contact Object and i am retrieving all contacts and I need a collection Map of Parent Id (AccountId) as Key and the collection of contacts related to AccountId .In short in apex language terms Map<AccountId,List<Contacts>>

Here is the code that i have included as an example on how to form the collection of Map<Id,List<Contact>>



Hope you enjoyed the technique .Happy coding !Let me know the feedback on the Post.

Thursday, 4 July 2013

Tips On Passing Advanced Developer Salesforce Certification Programming Assignment

As promised as per my previous blog i am sharing my experience on how to clear the advanced developer programming assignment and essay exams to obtain the Advanced Developer Certification.

One of the basic things i would like to mention is ,this you will not have it  overnight as the demand for the course is very high and there are limited slots available in each quarter .One has to be very sharp to quickly register for the exam on the dates mentioned in the certification.salesforce.com. Small negligence  will cause you to wait for another 2 to 3 months .

The assignments are distributed nearly after a month once you have registered .So this gives ample amount of time to revise your apex and visualforce skills.

Once the assignments are distributed you will have nearly a month time to complete your assignment and i would suggest reading the whole pdf that comes with assignment more than thrice atleast to make sure you understand the logical requirements and the hidden aspects of the assignments .

Usually a month time is enough for this but one has to make sure they spend atleast one weekend (Assuming your office timings are hectic and you have lot of work to cover on weekdays)

While doing assignment remember few key points 

1)Follow best practices while designing your trigger and visualforce controllers .Some of the reference links for the wiki articles that helped me  are below 

http://wiki.developerforce.com/page/The_Path_to_Advanced_Developer_Certification

http://wiki.developerforce.com/page/Apex_Code_Best_Practices

http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods

http://wiki.developerforce.com/page/Apex_Code_Best_Practices

http://wiki.developerforce.com/page/Enforcing_CRUD_and_FLS


2)Testing is the most important aspect that is looked when your assignments are evaluated .Make sure you have adequate test methods with proper asserts 

3)Your application will also be evaluated as per security guideline's so make sure you understand the best practices for writing a secure code 


What does an Essay Examination consists of ?

Essay exams are just to evaluate that you have yourself designed the application and written the code .A Simple descriptive questions will be thrown that you should be good if you yourself have written the code .

To understand more on this i would suggest you to read the below article which is one of the best articles written so far on this subject


Hope you enjoyed this short read and its informational.Let me know your feedback on this article .

Saturday, 22 June 2013

Fun with Angular Js and Visualforce Page

Recently i authored a visualforce page just to demonstrate the use of angular JS (Javascript framework from google ).It was very good experience working with Harshit Pandey.

The idea was just to demonstrate how easily even with getters concept of visualforce one can bind data to the angular JS script

The page gives functionality of sorting ,pagination and searching all in a single UI.The UI is done through twitter bootstrap plugin.

The page code can be found below


The controller code is very simple and its just returning JSON object

The same post is posted by Harshit in a friendly format .You can find at following link http://www.oyecode.com/2013/06/getting-started-with-angularjs-on.html

Thanks and Happy Coding !

Monday, 3 June 2013

Using CSS in pdf for page numbering with API 28.0 (@page CSS properties)

Generating PDF in salesforce is very easy with renderAs="pdf" attribute of apex page tag.For those of you needing sample on how to achieve this ,the below link points in right direction to get started and create some professional documents using some CSS power and Visualforce tags

http://wiki.developerforce.com/page/Creating_Professional_PDF_Documents_with_CSS_and_Visualforce

With API 28.0 my designed visualforce pages stopped showing the pagenumbers and other CSS attributes using style with @page annotations .

Here is the code that i tried in sample page to figure the issue with less code



  
  


This code yielded a pdf with no page number and hence conclusion that the @page CSS style properties are not working in API 28.0
Now the question arises like why it works in API 27.0 and not in API 28.0 .To understand this i read enhancements that came in API 28.0 on visualforce .I inserted html tag at start in API 27.0 and found again that @page attribute was not working.Hence injection of html above the head tag creates the issue .

To remove the issue i used the API 28.0 feature to stop the injection of html tag. Here is the working code



  
  

Setting applyHtmlTag as false stops the injection of the html tag and hence the page again started working as expected in API 28.0

Saturday, 11 May 2013

Mobile Application Development On Force.com Touch Platform-Part 3

This is in continuation with my previous posts .This post basically covers the difference between local and server side implementation approach for developing cross platform hybrid  mobile application on touch platform.

An hybrid mobile application is cross platform and generally use phonegap that comes bundled with mobile SDK to develop the application. Web developers familiar with the javascript will find it very friendly to learn and develop hybrid mobile application.

The following table below summarizes the difference and comparison between local(javascript on local device and using ForceTK/RemoteTk  library) and server side(Visualforce with Javascript Remoting) approach:



Local/ServerSide Hybrid mobile application development on touch platform
Feature local Approach using mobile packs(Backbone js/angulur js/jquerymobile) Server side Approach using Visualforce page
Databinding ForceTK or RemoteTK,Javascript modal functions for angular js or backbone js library functions Javascript Remoting can be used
Offline Support Smartstore.js can be used to achieve .Its relatively easier to provide this functionality in local side approach Html5 app cache concept can be used to provide offline(Not secure ,Smartstore Recommended),Browser capacity to store data is limited and hence if offline is major part of requirement its essential to develop with local side approach
Packaging Repeated Packaging for any changes to the application Less Frequent packaging due to One Time SFDC Package Deployment
SFDC API Remote TK consumes no API calls and hence can be used to save API calls,ForceTK consumes API call Visualforce Remoting feature and hence API calls are only consumed for DML operations
Code Storage The javascript library,CSS and whole code resides on the device The main javscript is written inside the visualforce pages
User Interface Jquery mobile can be used to provide good user interface.With angular and backbone libraries such as bootstrap can be used Jquery mobile is preferred .Although no hard rule ,any UI CSS library can be kept in static resource and used to develop mobile friendly UI
Development Effort The developer must be good in CSS,HTML5 and must be familiar with javscript libraries like angular or backbone.js The knowledge of visualforce ,jquerymobile and apex remoting is enough to develop server side hybrid application


The conclusion is at this point it really depends on the requirement to adopt which development model to prefer depending on the requirements .

Reference

http://www2.developerforce.com/mobile/

Introducing Lightning Base Components

Lightning Base Components are great addition to the platform and in fact revolutionary .One of the concerns around lightning component ...