Ads

Thursday, 16 May 2013

What is Salesforce.com?


Salesforce.com is a web based CRM tool that helps us to maintain the relationship with the customers.

Salesforce.com is a good example for Cloud computing services.

Salesforce.com uses Multi tenant architecture.

Leaders in cloud computing systems for customer relationship management, CRM, sales, social, call centre, knowledge management software cloud computing.

How to find object type from Salesforce record id?

Visualforce page:

<apex:page Controller="sample" sidebar="false" >
<apex:form >
    <apex:pageblock id="pg" >
        <apex:pageblockSection >
            <apex:pageBlockSectionItem >Record Id</apex:pageBlockSectionItem>
            <apex:pageblockSectionItem ><apex:inputtext value="{!recId}" /></apex:pageblockSectionItem>
        </apex:pageblockSection>
        <apex:pageBlockButtons >
            <apex:commandButton value="Find" action="{!find}" reRender="pg"/>
        </apex:pageBlockButtons>
        <apex:outputText >The object type is : {!objType}</apex:outputText>
    </apex:pageblock>
</apex:form>  
</apex:page>


Apex: Controller:

public with sharing class sample
{
    public Id recId {get;set;}
    public String output {get;set;}
    public Schema.SObjectType objType {get;set;}
   
    public void find()
    {
        objType = recId.getSobjectType();
        System.debug('Object Type is ' + objType);
    }
}


Output:


Sunday, 5 May 2013

To send parameters from one visualforce page to another?

The below code is used to send parameters from one visualforce page to another visualforce page. 

Visualforce:

<apex:outputlink value = "/apex/sample">
  <apex:param name = "msg" value = "hi"/>
</apex:outputlink>

Apex:

public String message = System.CurrentPagereference().getParameters().get('msg');

Friday, 3 May 2013

To get values from input field in controller extension using Apex?

The following code explains how to get values from <apex:inputfield> in controller extension using apex 

Visualforce:

  <apex:pageblock title="Blog" mode="edit" >
    <apex:pageBlockButtons >
      <apex:commandButton action="{!nxt}" value="Next"/>
    </apex:pageBlockButtons>
    <apex:pageBlockSection columns="1">
      <apex:inputField value="{!Blog__c.name}"/>
      <apex:inputField value="{!Blog__c.URL__c}"/>
    </apex:pageBlockSection>
  </apex:pageblock>

Apex:

  Public Blog__c blg; 
  this.blg = (Blog__c)controller.getRecord();

  String nam = blg.name;
  Sting url = blg.URL__c;

Like operator in SOQL query in JAVA and C#

String sql = 'SELECT Name,Id FROM Account WHERE Name Like '%' + acctName + '%'';

Here 'acctName' is a variable.

Convert List to Set in Salesforce?

The simplest way to convert List to Set in Salesforce is given below:       

        List<String> tempList = new List<String>();
        Set<String> tempSet = new Set<String>();
        
        tempList.add('One');
        tempList.add('Two');
        tempList.add('Three');  
        
        tempSet.addAll(tempList); 


tempList is List datatype and tempSet is Set datatype.
Add some values to List datatype and use addAll() to add it to Set datatype.

Component in Salesforce?

In Salesforce component is a reusable piece of code developed using Visual force and Apex controller.

Example:

<!-- Page -->

<apex:page>

    <c:myComponent myValue="My component's value" borderColor="red" />

</apex:page>


<!-- Component:myComponent -->     
<apex:component>

    <apex:attribute name="myValue" description="This is the value for the component."  type="String"required="true"/>

    <apex:attribute name="borderColor" description="This is color for the border."  type="String" required="true"/>

    <h1 style="border:{!borderColor}">

        <apex:outputText value="{!myValue}"/>

    </h1>

</apex:component>