Skip to main content

Posts

Showing posts from September, 2012

Tips On Passing Advanced Developer Salesforce Certification(501) multiple Choice Questions

I am glad to share that i cleared Advanced Developer first round .There are already good number of blogs on how to approach this exam.

Following blogs are really good resource and also they give a fair amount of idea on how to approach and how to clear this exam.

1)http://blog.jeffdouglas.com/2009/07/13/i-passed-the-salesforce-com-certified-advanced-developer-exam-so-can-you/
2)http://corycowgill.blogspot.in/2011/05/passing-forcecom-advanced-developer-501.html
3)http://exploresalesforce.blogspot.in/2012/01/how-to-clear-dev-501-exam.html
4)http://www.laceysnr.com/2011/12/five-oh-one-part-one-advanced-developer.html
5)http://limitexception.herod.net/2011/12/14/helping-you-pass-your-501-advanced-developer-exam/

Now my aim is to provide some more points on how to go about it.Please dont refer any dumps or ask for dumps as it is not the purpose of examination .

1)Dont jump into the exam as soon as you clear DEV-401 (developer certification)
2)If you are a developer on the platform and extensiv…

New ID.getSObjectType Method in Apex version 26 (Part of winter 13 release)

While i was going through winter 13 release notes of salesforce one of the interesting feature i found was addition of new method ID.getSObjectType.
This will be very helpful in getting the object token without making one more describe call if already in the code we have the List of ID's or ID.
Here is the small snippet i ran in new enhanced developer console(Pretty excited about this new console)
Id accid=[Select Id from Account Limit 1].ID; Schema.Sobjecttype inspecttype=accid.getSObjectType(); system.debug('Object Token '+inspecttype); 23:33:30:025 USER_DEBUG [3]|DEBUG|Object Token Account As seen above this method works great if your sandbox has been updated
Also this method will help in methods where only primitive types can be passed as a parameter like @future where parameter cannot be sObject.

Chaining of Batches in APEX no more pain

Starting a Batch Job from Another Batch Job You can now start a batch job from another batch job by calling Database.executeBatch from the finish method of the batch class. This allows you to link your batch jobs and create a chain of jobs. Note that the governor limits of batch jobs still apply. This change applies to batch Apex saved using Salesforce.com API version 26.0 and later. Previously, with Apex saved using Salesforce.com API version 25.0 and earlier, you couldn’t call Database.executeBatch from within any batch Apex method. The version used is the version of the running batch class that starts another batch job. If the finish method in the running batch class calls a method in a helper class to start the batch job, the Salesforce.com API version of the helper class doesn’t matter.

Importance of Virtual Keyword in Apex and when to use Virtual keyword

I have less experience on Java Programming and hence posting this for all those who are familiar with basics of apex but unfamiliar with OOPS concepts like inhertience and polymorphism of JavaProblem description:I knew that the virtual keyword is used to extend a class and thanks to great documentation from salesforce.(http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_example.htm) But my problem is no where in document it is mentioned how to proceed if in my parent class there is a parameterized constructor .Example: global virtual class sobjectWrapper{ sobject sobjectDetails; String RefreshFlag=''; public sobjectWrapper(sobject r){ sobjectDetails=r; } } As seen in the above code there is a parametrised constructor.First i attempted to write the extended the class as shown below global class extutilility extends sobjectWrapper{ sobject sobjectDetails; String RefreshFlag=''; private string abc; extutilility(sobject r){ sobjectDetails=r } } A…

How to generate a Listed JSON from multiple Salesforce Objects(say account and contact) and send data in JSON format to mobile client without nesting Using REST API

Sometimes there is a request for listed JSON .Say we have two objects Accounts and Contacts and we have requirement not to nest the response instead send as a collection with key for list of Accounts as Account and key for Contact as Contact.Below is the JSON format thats expected output, { "Accounts": [ { "attributes": { "type": "Account", "url": "/services/data/v25.0/sobjects/Account/001W0000006XDG9IAO" }, "CreatedDate": "2012-08-09T08:29:43.000+0000", "LastModifiedDate": "2012-08-09T15:24:42.000+0000", "IsDeleted": true, "Id": "001W0000006XDG9IAO" }, { "attributes": { "type": "Account", "url": "/services/data/v25.0/sobjects/Account/001W0…

Few Intresting Tips On Making a Field Mandatory On Visualforce Page

Inspecting the CSS of the salesforce and playing around a bit we can easily make a field look like a required field with the help of below snippetThe validation can be easily handled at the back end and a small code that will be helping is below if(is error){ ApexPages.addmessage(new ApexPages.Message(ApexPages.Severity.Error, 'Error Message.........')); } tag has to be added in the page to display the error to the user.

Handling Exceptions In REST API wrappers in salesforce and setting proper HTTP error in header of HTTP response sent from Salesforce

To set the proper error code in the response packet returned from salesforce there is default HTTP error code tableThe documentation of valid http error codes supported is in the http response is accessed on clicking below Documentation on HTTP error codesTo handle this in code here is a below simple example that demonstrates how to set the HTTP error codes in salesforce @RestResource(urlMapping='/Account/*') global with sharing class accountrest { @HttpGet global static Account getMerchandiseById() { RestRequest req = RestContext.request; RestResponse res=RestContext.response; Account result; String accId = req.requestURI.substring( req.requestURI.lastIndexOf('/')+1); try{ result =[SELECT Name,AccountNumber,NumberofLocations__c FROM Account WHERE Id = :accId]; } catch(exception e){ System.debug(e.getMessage()); res.statusCode=400;//clear that error was due to account ID missing and hence BAD request } return result; }

cloudy: Using POSTER mozilla tool to get oauth token and access the REST API of salesforce

Using POSTER mozilla tool to get oauth token and verifying response from REST API salesforce Please follow the following steps:


1)https://login.salesforce.com/services/oauth2/token Use this first as a request URL to get access token .Please use test.salesforce.com for sandbox

2)To obtain access token you must Use POST http call: In the payload use

grant_type=password&client_id=<your_client_id>&client_secret=<your_client_secret>&username=<your_username>&password=<your_password>

where client id,client secret you will get from your remote access settings and please append security token if you are making from unautorized IP range .Please use appropriate User Name and Password

3)Once you POST to the service you will get acess token .Please save that for future requests

4)Next in the header add following parameter and its value as  Name:Authorization Value:Bearer +oauthtoken obtained (Bearer space and your oauth_token)

5)Now once you add header in requ…