Author Archives: Biswajeet

About Biswajeet

Biswajeet is my Name, Success is my Aim and Challenge is my Game. Risk & Riding is my Passion and Hard Work is my Occupation. Love is my Friend, Perfection is my Habit and Smartness is my Style. Smiling is my Hobby, Politeness is my Policy and Confidence is my Power.

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 Parameters From One Visualforce Page To Another Visualforce Page

First Visualforce Page:

<apex:page>
    <apex:outputLink value="/apex/SecondPage">Click Here
    	<apex:param name="name" value="Biswajeet Samal"/>
    </apex:outputLink>
</apex:page>

Second Visualforce Page:

<apex:page controller="SecondPageController">
    Hello {!name}
</apex:page>

Second Page Controller:

public class SecondPageController {
    public String name {get;set;}
    
    //Constructor
    public SecondPageController(){
        name = System.currentPageReference().getParameters().get('name');
    }
}

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

EmailMessage in Salesforce

“EmailMessage” represents an email in Salesforce.

EmailMessage Supported Calls:

  • create()
  • delete()
  • describeLayout()
  • describeSObjects()
  • getDeleted()
  • getUpdated()
  • query()
  • retrieve()
  • undelete()
  • update()
  • upsert()
  • EmailMessage is only available for organizations that use Email-to-Case or Enhanced Email, which is automatically enabled for most customers.
  • Customer Portal users have read access to EmailMessage if the value for the ParentID field is associated with a case. Otherwise, access is determined by sharing access of the associated task.
  • update() is supported only on records whose Status is Draft. When a record’s Status is not Draft, update() is supported only for the IsExternallyVisible field and custom fields.

Fields in EmailMessage:

Field Label API Field Name Type Length Properties Description
Activity ActivityId reference 15 Create, Filter, Group, Nillable, Sort ID of the activity that is associated with the email. Usually represents an open task that is created for the case owner when a new unread email message is received.
BCC Ids BccIds JunctionIdList Create, Update A string array of IDs for contacts, leads, and users who were sent a blind carbon copy of the email message. Each ID is linked to an EmailMessageRelation record, which represents the relationship between an email message and a Contact, Lead, or User record.
BCC Address BccAddress string 4000 Create, Filter, Nillable, Sort, Update A string array of email addresses for recipients who were sent a blind carbon copy of the email message. This field should include only email addresses that are not associated with Contact, Lead, or User records in Salesforce. If the recipient is a contact, lead, or user, add their ID to the BccIds field instead of adding their email address to the BccAddress field. Then the email message is automatically associated with the contact, lead, or user.
CC Address CcAddress string 4000 Create, Filter, Nillable, Sort, Update A string array of email addresses for recipients who were sent a carbon copy of the email message. This field should include only email addresses that are not associated with Contact, Lead, or User records in Salesforce. If the recipient is a contact, lead, or user, add their ID to the CcIds field instead of adding their email address to the CcAddress field. Then the email message is automatically associated with the contact, lead, or user.
CC Ids CcIds JunctionIdList Create, Update A string array of IDs for contacts, leads, and users who were sent a carbon copy of the email message. Each ID is linked to an EmailMessageRelation record, which represents the relationship between an email message and a Contact, Lead, or User record.
Created By CreatedById reference 15 Defaulted on create, Filter
Created Date CreatedDate datetime Defaulted on create, Filter
Deleted IsDeleted boolean Defaulted on create, Filter Indicates whether the object has been moved to the Recycle Bin (true) or not (false). Label is Deleted.
EmailMessage ID Id id 15
From Address FromAddress email 1000 Create, Filter, Nillable, Update The address that originated the email.
From Name FromName string 1000 Create, Filter, Nillable, Update The sender’s name.
HTML Body HtmlBody textarea 32000 Create, Nillable, Update The body of the email in HTML format.
Has Attachment HasAttachment boolean Defaulted on create, Filter Indicates whether the email was sent with an attachment (true) or not (false).
Headers Headers textarea 32000 Create, Nillable, Update The Internet message headers of the incoming email. Used for debugging and tracing purposes. Does not apply to outgoing emails.
Is Incoming Incoming boolean Create, Defaulted on create, Filter Indicates whether the email was received (true) or sent (false).
Is Client Managed IsClientManaged boolean Create, Defaulted on create, Filter, Group If EmailMessage is created with IsClientManaged set to true, users can modify EmailMessage.ContentDocumentIds to link file attachments even when the Status of the EmailMessage is not set to Draft.
Is Externally Visible IsExternallyVisible boolean Create, Defaulted on create, Filter, Group, Update If the community case feed is enabled, IsExternallyVisible controls the external visibility of emails in communities. When IsExternallyVisible is set to true—its default value—email messages are visible to external users in the case feed.
Only emails with the ParentId field populated are available to be externally visible in communities.
This field can’t be updated if the email’s Status is set to Draft.
Last Modified By LastModifiedById reference 15 Defaulted on modify, Filter
Last Modified Date LastModifiedDate datetime Defaulted on modify, Filter
Message Date MessageDate datetime Create, Filter, Nillable, Update The date the email was created.
Message Identifier MessageIdentifier string 255 Create, Filter, Group, Nillable, Sort, Update The ID of the email message.
Parent Case ParentId reference 15 Create, Filter, Group, Nillable, Sort ID of the case that’s associated with the email.
Related To Id RelatedToId reference 15 Create, Filter, Group, Nillable, Sort The RelatedToId represents nonhuman objects such as accounts, opportunities, campaigns, cases, or custom objects. RelatedToIds are polymorphic. Polymorphic means a RelatedToId is equivalent to the ID of a related object.
Reply-to Email Message ReplyToEmailMessageId reference 15 Create, Filter, Group, Nillable, Sort ID of the inbound or outbound EmailMessage the current EmailMessage is a reply to. It’s not possible to reply to a message whose Status is Draft.
Status Status picklist 40 Create, Filter, Restricted picklist, Update Read only. The status of the email. For example, New, Draft, Unread, Replied, or Sent.
Subject Subject string 3000 Create, Filter, Nillable, Update The subject line of the email.
System Modstamp SystemModstamp datetime
Thread Identifier ThreadIdentifier String 255 Create, Filter, Group, Nillable, Sort, Update The ID of the email thread the email message belongs to.
Text Body TextBody textarea 32000 Create, Nillable, Update The body of the email, in plain text format.
To Address ToAddress string 4000 Create, Filter, Nillable, Update A string array of email addresses for recipients who were sent the email message. This field should include only email addresses that are not associated with Contact, Lead, or User records in Salesforce. If the recipient is a contact, lead, or user, add their ID to the ToIds field instead of adding their email address to the ToAddress field. Then the email message is automatically associated with the contact, lead, or user.
Validate From Address ValidateFromAddress picklist Create, Filter, Nillable, Update A string array of email addresses for recipients who were sent the email message. This field should include only email addresses that are not associated with Contact, Lead, or User records in Salesforce. If the recipient is a contact, lead, or user, add their ID to the ToIds field instead of adding their email address to the ToAddress field. Then the email message is automatically associated with the contact, lead, or user.

EmailMessage Usage:
If your organization uses Email-to-Case, a case is created when an email is sent to one of your company’s addresses. The email, which is related to the case by the ParentID field, is stored as an EmailMessage record. When users view the email, they see the EmailMessage record.

If your organization uses Enhanced Email, each email is stored as an EmailMessage record and a Task record. When users view an email, they see the EmailMessage record.

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;