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









Wednesday 23 January 2013

How to use apex:variable in apex:pageblocktable & apex:repeat

Hi,

This is a cool little script that will tell you how to use apex:variable in visualforce page.
Basically this is nothing but a counter in apex:repeat & apex:pageBlockTable:

    
        
      





In apex:pageBlockTable :

       
             
        
               
    
    
     
     
    
    
 


to get more detail information please Click Here

Thanks
Sandeep


Sunday 20 January 2013

Know Your Salesforce System Status

Hi,

If you are facing some problem while logging your salesforce org. then please visit here to get the reason.
Click Here



Tuesday 1 January 2013

How to get Record Type Id without SOQL

Whenever we would like to fetch data from Database SOQL comes as first option in our mind but it will be added in query consumption limit. Here is a way to do this without any query:

// User need to pass two parameters SObject Type & 
    //RecordType Label ( not Record Type Developer Name)
    public static ID getRecordTypeId(String ObjectType, String RecordTypeLabel)
    { 
      SObject OBJ;
      // Describing Schema
      Schema.SObjectType Res = Schema.getGlobalDescribe().get(ObjectType);
      if (Res != null)
      {
  OBJ = Res.newSObject();
  // Describing Object 
  Schema.DescribeSObjectResult DesRes = OBJ.getSObjectType().getDescribe(); 
  if (DesRes != null)
  {
            Map RecordTypeMap =      DesRes.getRecordTypeInfosByName();
     if (RecordTypeMap != null) 
     {
        Schema.RecordTypeInfo RecordTypeRes = RecordTypeMap.get(RecordTypeLabel);
        if (RecordTypeRes != null) 
        {
           return RecordTypeRes.getRecordTypeId();
        }
      }
   }
        }
 return null;
    } 
Let's say there are two Record Type of Account so we can get Record Type ID of Account Like this
ID RecordTypeId = getRecordTypeId('Account' , 'RecordType1');

Best Regards
Sandeep