Thursday, 31 January 2013

Spring ‘13 Cloud Trivia

Hi friends,

Spring ‘13 expertise gets over with full of enthusiasm and I have collected all questions and answers for all of who missed the event.

Q: By what name were ‘Connected Apps’ previously known?
A: Remote Access apps

Q: What is the authorization protocol used by Connected Apps?
A: OAuth 2.0

Q: What 4 kinds of code artifact can the Tooling API manage?
A: Apex Classes, Apex Triggers, Visualforce Pages, Visualforce Components

Q: Which other Force.com API allows you to deploy code?
A: The Metadata API

Q: Which new tab was added to the Developer Console?
A: ‘Progress’

Q: Connect in Apex also known as the ___(a)___ API is the native representation of the ___(b)___ API.
A: a. Connect b. Chatter

Q: What VF component attribute allows you to send controller data into your Canvas app?
A: Parameters

Q: What standard field that was formally read only is now writable on update?
A: ID

Q: What are two new object triggers you can create for chatter in Spring 13?
A: CollaborationGroup and CollaborationGroupMember

Q: What does Force.com Canvas use to prevent XHR problems posting back to Salesforce?
A: JavaScript SDK

for more daily updates visit official SalesforceClub to get winner list


Best Regards
Sandeep

Tuesday, 29 January 2013

Execute SOQL On Chatter in Salesforce

Today I am providing a piece of code which will introduce a new way to run your simple SOQL on Chatter it self without opening developer console(that might take some time while loading).

To use this tool you just need to keep this trigger code in your org and then you can execute simple SOQL queries as follows.

Step1 : Post a SOQL in chatter on any object in the org.
Step2 : Refresh the screen you will get your result as below.


trigger ChatterAsConsole on FeedItem (after insert)
{   
    if(UtilClass.noOfExecution == 0)
    { 
        String queryString = '';  
        FeedItem post ; 
        for (FeedItem f: trigger.new)
        {  
            Try
            {                 
                //Adding a Text post
                post = new FeedItem();
                post.ParentId = f.ParentId; //eg. Opportunity id, custom objectid
                queryString = f.Body ;
                String idString = '';
                
                for(Sobject s : Database.query(queryString))
                {
                        idString += s.id+', ';
                }        
                if(idString.endsWith(', '))
                    idString = idString.substring(0,idString.length()-2);
                post.Body = idString ;
                UtilClass.noOfExecution ++ ;
                insert post;
            }catch(Exception e)
            {
                post = new FeedItem(ParentId = f.ParentId , Body  = e.getMessage() );
                insert post;
            }
        }
    }
}
Helper Class : 
public Class UtilClass
{
 public static Integer noOfExecution = 0; 
}

This code has its own limitation but you can customize it as per your need.

Best regards
Sandeep