Aug 13, 2014

Not sure why you attend Dreamforce?

Dreamforce is on it's way, and we all are excited about it (me for sure). If you are still not sure you should attend Dreamforce then below is some awesome stuff which you'll be missing.

-> Best part is the DEV ZONE for developers like me, a lot of fun stuff there like super awesome breakout sessions, theaters and FREE books :-)


Along with this you will find these people walking around you and you can say HI! to them, April, Patt Peterson, Raja Rao, Kavindra Patel, Sandeep Bhanot (list is very very long, please forgive me if I've not written all the names as for that I'll need another blog post :-) )


-> Besides Dev Zone, most important part is the networking. You can meet people who are related to different area. Say if you are running your own business, you will get a change to connect with lot of ISVs or small/big company owners who can help you with your business. If you are emerging developer, then you can connect with Salesforce Developer Evangelists, Salesforce Developer Relationship Managers etc. Confused how to connect with them? Twitter is the best way to follow them and connect with them.


-> Some other benefits are you'll get to know about the latest trends and how world is growing with Salesforce. Say what's new with Salesforce1, what's new on mobile side and stuff. Superb keynote sessions, and our very own Marc Benioff's session and Q&A. Hands on training and code consulting session, again list is very long.


To know more visit this link http://bit.ly/df14infblog


-> I'll also be speaking and my session is "FYFOF - Find Your Feet On Force.com", so if you are a beginner or want to learn how you can grow with Salesforce then I hope to see you in my session.


Don't worry about the long flight to SFO (if you are going from India) and expense as it's worth it. So be ready with your visa and book your tickets now before you are too late (Dreamforce 14 is between 13-16 Oct 2014)


Hope to see most of you at Dreamforce.

Jun 30, 2014

Summer 14 Release - Developer Must Know These

So Summer 14 release is almost there and in few more days it will be in our organizations. So are we ready to us the new features/changes?



Let's go through some points which a developer must know, to write Apex/VFP in better way. 

List is as follows :

1) Attach upto 25 MB of files now with objects, earlier it was 5 MB. But, attachment limits in Salesforce Knowledge remain unchanged. So go on and use large data files.

2) Limits for all Apex describe calls have been removed for all API versions. Describe calls include describes for sObjects, fields, field sets, child relationships, picklists, and record types. In other words say no to, ONLY? 100 fields or fieldsets or objects. Yes now we are free :-)



Will these be now needed?

- getLimitChildRelationshipsDescribes()
- getLimitFieldsDescribes()
- getLimitFieldSetsDescribes()
- getLimitPicklistDescribes()
- getLimitRecordTypesDescribes()

3) The Limits methods for script statements have been removed but are available and deprecated in API version 30.0 and earlier. Because the script statement limit is no longer enforced in any API version since Winter ’14, the associated Limits methods are no longer needed. Now no need of getScriptStatements() and getLimitScriptStatements()

4) Now you can create price book entries for standard and custom price books in Apex tests. Previously we were not able to create price book entries and for that we've to use @isTest(seeAllData = true) annotation. So now we can create custom pricebook along with the pricebook entries in test classes itself. Now we can

- Query for the ID of the standard price book in organization with the Test.getStandardPricebookId() method.
- Create test price book entries with standard prices by using the standard price book ID that’s returned by Test.getStandardPricebookId().
- Create test custom price books, which enables you to add price book entries with custom prices.

5) Run future methods with higher limits, unbelievable isn't it? But currently it's in pilot. By this we can avoid reaching governor limits and we can double or triple the capacity of resources like for heap size we can write this @future(limits='2xHeap'), for SOQL @future(limits='2xSOQL') and so on. Fascinating isn't it, eagerly waiting for this to be implemented completely.



6) Chatter in apex. Lot of stuff in this, and difficult to summarize it here would recommend to read release notes.

7) API request in developer edition was 5,000 and now it's raised to 15,000. So now we can do some real time testing along with development.

Lot of stuff to be improved in current code and am on it, are you?

May 11, 2014

Google Drive Authentication In Salesforce - Easy Steps (Authentication Part 2)

Now where comes part 2 of authentication. This time it's with Google Drive.

In this blog Authentication with Google is explained so developers can get started.

Step 1 : Create  account on google (hope you already have), then go to developer console to create a project. Now click on project which is newly created then click on APIs and auth > APIs and make Drive API "on".

Step 2 : Now "Create New Client ID " which will look something like this :


Now we will use this info in salesforce to authenticate.

Step 3 : Create this apex class in Salesforce

public class GoogleDriveController
{
    //Fetched from URL
    private String code ;
    private string key = '134427681112-ld4vp2l1jut3aj2fktip776081nhn8l3.apps.googleusercontent.com' ;
    private string secret = 'hdHNk4GjNtkR4nNL1SqCfRk_' ;
    private string redirect_uri = 'https://c.ap1.visual.force.com/apex/GoogleDrivePage' ;
    
    public GoogleDriveController()
    {
        code = ApexPages.currentPage().getParameters().get('code') ;
        //Get the access token once we have code
        if(code != '' && code != null)
        {
            AccessToken() ;
        }
    }
    
    public PageReference DriveAuth()
    {
        //Authenticating
        PageReference pg = new PageReference(GoogleDriveAuthUri (key , redirect_uri)) ;
        return pg ;
    }
    
    public String GoogleDriveAuthUri(String Clientkey,String redirect_uri)
    {
        String key = EncodingUtil.urlEncode(Clientkey,'UTF-8');
        String uri = EncodingUtil.urlEncode(redirect_uri,'UTF-8');
        String authuri = '';
        authuri = 'https://accounts.google.com/o/oauth2/auth?'+
        'client_id='+key+
        '&response_type=code'+
        '&scope=https://www.googleapis.com/auth/drive'+
        '&redirect_uri='+uri+
        '&state=security_token%3D138r5719ru3e1%26url%3Dhttps://oa2cb.example.com/myHome&'+
        '&login_hint=jsmith@example.com&'+
        'access_type=offline';
        return authuri;
    }
    
    
    public void AccessToken()
    {
        //Getting access token from google
        HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint('https://accounts.google.com/o/oauth2/token');
        req.setHeader('content-type', 'application/x-www-form-urlencoded');
        String messageBody = 'code='+code+'&client_id='+key+'&client_secret='+secret+'&redirect_uri='+redirect_uri+'&grant_type=authorization_code';
        req.setHeader('Content-length', String.valueOf(messageBody.length()));
        req.setBody(messageBody);
        req.setTimeout(60*1000);

        Http h = new Http();
        String resp;
        HttpResponse res = h.send(req);
        resp = res.getBody();
        
        System.debug(' You can parse the response to get the access token ::: ' + resp);
   }
}


Step 4 : Create this visualforce page (GoogleDrivePage) in Salesforce



    
        
    




Step 5 : Replace the code :

You can replace these three variables according to your settings (created in step 2)

private string key = '134427681112-ld4vp2l1jut3aj2fktip776081nhn8l3.apps.googleusercontent.com' ;
private string secret = 'hdHNk4GjNtkR4nNL1SqCfRk_' ;
private string redirect_uri = 'https://c.ap1.visual.force.com/apex/GoogleDrivePage' ;

Step 6 : Don't forget to create remote site setting :


Step 7 : All set to go, now hit the page "https:// ..... /apex/GoogleDrivePage", make sure your debug is on. Once authenticated with google debug will print the access token.


Now you can use this access token for further requests.

Please note, code is not beautified as this is just to explain how you can authenticate google with salesforce. A lot more creativity can be applied here.


Happy Coding!!

May 9, 2014

Dropbox Authentication In Salesforce - Easy Setup (Authentication Part 1)

From log time managing data is a big deal, and a lot are concerned with it. Multiple options are available to handle this, out of them Dropbox, Box.com, Amazon are the main ones.

In this blog Authentication with Dropbox is explained so developers can get started.

Step 1 : Create an account on Dropbox, then go to this link and create an app. It will create "App Key" and "App Secret" which we will be using in Salesforce. Leave the OAuth2 section blank for now.


Step 2 : Go to salesforce and create this apex class (DropboxController) :

public class DropboxController
{
    //Fetched from URL
    String code ;
    
    public DropboxController()
    {
        code = ApexPages.currentPage().getParameters().get('code') ;
        //Get the access token once we have code
        if(code != '' && code != null)
        {
            AccessToken() ;
        }
    }
    
    public PageReference DropAuth()
    {
        //Authenticating
        PageReference pg = new PageReference('https://www.dropbox.com/1/oauth2/authorize?response_type=code&client_id=vaabb5qz4jv28t5&redirect_uri=https://c.ap1.visual.force.com/apex/DropboxPage&state=Mytesting') ;
        return pg ;
    }
    
    public void AccessToken()
    {
        //Getting access token from dropbox
        String tokenuri = 'https://api.dropbox.com/1/oauth2/token?grant_type=authorization_code&code='+code+'&redirect_uri=https://c.ap1.visual.force.com/apex/DropboxPage'; 
        HttpRequest req = new HttpRequest();
        req.setEndpoint(tokenuri);
        req.setMethod('POST');
        req.setTimeout(60*1000);
          
        Blob headerValue = Blob.valueOf('vaabb5qz4jv28t5' + ':' + 'dpmmll522bep6pt');
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        Http h = new Http();
        String resp;
        HttpResponse res = h.send(req);
        resp = res.getBody();
        
        System.debug(' You can parse the response to get the access token ::: ' + resp);
   }
}


Step 3 : Now create visualforce page (DropboxPage) :



    
        
    




Step 4 : Replace the code with your values

1 . As you can see we have this in code :

PageReference pg = new PageReference('https://www.dropbox.com/1/oauth2/authorize?response_type=code&client_id=vaabb5qz4jv28t5&redirect_uri=https://c.ap1.visual.force.com/apex/DropboxPage&state=Mytesting') ;


You have to replace "client_id" with your "App Key" (redirect_uri is the complete page URL which we've just created). Now as visualforce page is created you can fill the OAuth2 section as shown in the screenshot above in dropbox.

2. Replace "dpmmll522bep6pt" in this line
Blob headerValue = Blob.valueOf('vaabb5qz4jv28t5' + ':' + 'dpmmll522bep6pt');
with you "App Secret"

Step 5 : Don't forget to set the remote site settings for dropbox



Now all set to go. Open the page "https:// ..... /apex/DropboxPage" and hit "Dropbox Authentication". In the debug you will get the access token which you can further use to hit Dropbox APIs.

Please note, code is not beautified as this is just to explain how you can authenticate dropbox with salesforce. A lot more creativity can be applied here.

From here everything is set and you are ready to hit the dropbox API and fetch the data or store the data. Complete documentation is here.

Happy Coding!!

May 7, 2014

Salesforce1 Developer Week - Jaipur Meetup

Salesforce organized a global event where around 70 Salesforce Developer Groups across the world talked about Salesforce1. We are proud to be part of the 1.5 Million developers in the Salesforce Developer Community and celebrated by taking part in Salesforce1 Developer Week on April 27th.

Special attraction of the event was Raja Rao DV (Developer Advocate, Salesforce.com) presented live in the group that what can be built using Salesforce1. Hope now every attendee learned what is Salesforce1 and how to get started.


Followed by Sandeep Singhal (Leader of Jaipur Salesforce Platform Student User Group) explained a little more introduction of Salesforce1 within Salesforce.


Now all were hungry, so it was time for lunch.


All set to go, here comes Amit Jain (Salesforce and Mobile Developer). Amit, presented on how we can develop an app by only points and clicks. It was making everything permanent in mind, what we've learned in last two sessions.


It was time to learn something advance, and who else is best to take this off. Gaurav Kheterpal (Mobile Guru, Salesforce Expert, Speaker, Author (space is not enough)) takes the show away by explaining mobilizing your apps with Salesforce1.




Workbooks were distributed to all, to get started. If you were not one of the attendee then here is the link to download it.


In the end the most awaited part of the event "The Quiz". Where super cool T-Shirts were distributed to all winners.



Over all it was a great success and response from all was very good. If you want to join us in upcoming meetups please join us here.



For more pictures and details of the event visit here.