Tag Archives: Salesforce.com

Difference between SOQL and SOSL

SOQL(Salesforce Object Query Language):

  • SOQL is a Salesforce Object Query Language, retrieves the records from the database by using SELECT keyword.
  • SOQL is used if we know in which object the data is present.
  • In SOQL we can query data from single object and as well as multiple objects that are related to each other.
  • We can query on all fields of any datatype.
  • We can use SOQL in Triggers and classes.
  • We can perform DML operation on query results.

SOSL(Salesforce Object Search Language):

  • SOSL is a Salesforce Object Search Language, retrieves the records from the database by using the FIND keyword.
  • SOSL is used if we don’t know in which object the data is present.
  • We can retrieve multiple objects and field values efficiently when the objects may or may not be related to each other.
  • We can query only on fields whose data type is text, phone and Email.
  • We can use in classes but not in Triggers.
  • We cannot perform DML operation on search result.

What is the difference between Lookup relationship & Master detail relationship?

Look up relationship:

  • Parent field on child can be required or optional choice.
  • No impact on security and access.
  • If we delete parent record then child records are not deleted.
  • No limit to number of layers.
  • Up to 25 allowed for an object.
  • We can change parent object for child object.
  • Roll-up summary field is not allowed.

Master – Detail Relationship:

  • Parent field on child is required.
  • Access to parent determines access to children.
  • Deleting parent automatically delete children.
  • Limited number of layers.
  • Up to 2 allowed for an object.
  • We can’t change the parent object for child object once create. The only way is killing the both objects.
  • Roll-up summary field is allowed.

Pass variable to a custom label from visualforce page

To know more about custom label Click here
Step 1:
Go to Setup –> App Setup –> Custom Labels.
Step 2:

1

Step 3:
Here for dynamic populate custom label variable value, the custom label value has written like this “My name is {0} {1}”.

2

Step 4:
Now I’ll create an apex controller with two variable to send it custom label.

public class TestCustomLabel{
    public string FirstName{get;set;}
    public string LastName{get;set;}    
     
    public TestCustomLabel(){
        FirstName = 'Biswajeet';
        LastName = 'Samal';
    }
}

Step 5:
Now I’ll create a visualforce page and use the custom label with parameters in it. Here the first parameter “FirstName” is for custom label “{0}” and the second parameter “LastName” is for custom label “{1}”.

<apex:page controller="TestCustomLabel" tabstyle="Account">
    <apex:form>
        <apex:pageblock>
            <apex:outputtext value="{!$Label.TestCustomLabel}">
            <apex:param value="{!FirstName}">
            <apex:param value="{!LastName}">
            </apex:param></apex:param></apex:outputtext>
        </apex:pageblock>
    </apex:form>
</apex:page>

Here is the visualforce page output:

3

Custom label in visualforce page and apex Class

Custom labels are custom text values that can be accessed from Apex classes or Visualforce pages. The value of Custom label can be static or dynamic from visulaforce page and apex class. The values can be translated into any language Salesforce supports. Custom labels enable developers to create multilingual applications by automatically presenting information (for example, help text or error messages) in a user’s native language.
In this article I’ll demonstrate how to use custom labels in visualforce page and apex classes.

Note: We can create up to 5,000 custom labels for your organization, and they can be up to 1,000 characters in length.
Step 1:
Go to Setup –> App Setup –> Custom Labels.
Step 2:

download
Step 3:

2

Step 4:
Now I’ll create a visualforce page and use the custom label in it.

<apex:page tabstyle="Account">
   <apex:form>
     <apex:pageblock>
       <apex:outputtext value="Custom lable value is : ">
       <apex:outputtext style="font-weight: bold;" value="{!$Label.DemoCustomLabel}">
     </apex:outputtext></apex:outputtext></apex:pageblock>
   </apex:form>
</apex:page>

Here is the visualforce page output:

3

Now get custom label value in apex class.

string  LabelText = System.Label.DemoCustomLabel;