Category Archives: Salesforce

Product, Pricebook and PricebookEntry


  • Product object is a catalog of items or services that your organization sells.
  • A product may contain one or more different sets of prices (PriceBookEntry).
  • Products are represented by Standard Object – Product2.


  • Pricebook object store a list of products and services that your organization sells.
  • Each organization has one standard price book that defines the standard or generic list price for each product or service.
  • An organization can have multiple custom price books that can be used for specialized purposes, such as a discount price book, price books for different channels or markets, price books for select accounts or opportunities, and so on.
  • For some organizations, the standard price book might be the only price needed, but if you need to set up further price books, you can reference the standard price book when setting up list prices in custom price books.
  • PriceBooks are represented by Standard Object – Pricebook2.


  • PricebookEntry object is a product entry (an association between a Pricebook2 and Product2) in a pricebook.
  • This object allows products to be linked to standard price book or custom price book with a price for a given currency.
  • One price book entry is linked to only one product.
  • One price book entry can only appear in one pricebook.
  • One price book entry can be used in multiple line items. This also further creates flexibility for users to set their own prices.
  • PricebookEntry are represented by Standard Object – Pricebookentry

Data Model: PricebookEntry is the junction object between Product and Pricebook.

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 5.00 out of 5)

Displaying Static Resources Image in Lightning Component

To reference a specific resource in component markup, we can use $Resource.resourceName within an expression. resourceName is the Name of the static resource. In a managed packaged, the resource name must include the package namespace prefix, like $Resource.yourNamespace__resourceName.

Sample Code:

    <!-- Stand-alone static resources image file-->
    <img src="{!$Resource.resourceName}"/>
    <!-- Stand-alone static resources image file with Namespace-->
    <img src="{!$Resource.yourNamespace__resourceName}"/>
    <!-- Asset from an archive static resource image file-->
    <img src="{!$Resource.resourceName + '/assets/images/logo.png'}"/>
    <!-- Asset from an archive static resource image file with Namespace-->
    <img src="{!$Resource.yourNamespace__resourceName + '/assets/images/logo.png'}"/>

Custom Label in Salesforce

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. Custom labels are custom text values that can be accessed from Apex classes, Visualforce pages, or Lightning components. The values can be translated into any language Salesforce supports.

We can create up to 5,000 custom labels for your organization, and they can be up to 1,000 characters in length.

Setup | App Setup | Custom Labels | Click ‘New Custom Label’ Button

Fill in the details and Click ‘Save’ button.


Custom Label in Visualforce page:
$Label.CustomLabel for Visualforce page.

<apex:page standardController="Account">
<h1>Example for Custom labels</h1>

	<apex:outputLabel value="{!$Label.Message}"/>


Custom Label in Apex Class:
System.Label.Label_name for apex class

String msg = System.Label.Message; 


Custom Label in Lightning Component:
$Label.c.labelName for the default namespace.
$Label.namespace.labelName if your org has a namespace, or to access a label in a managed package.

<aura:component implements="flexipage:availableForAllPageTypes">
<div onclick="{!c.clickLabel}">
        <ui:outputText value="{!$Label.c.Message}" />



Custom Label in Javascript:
$A.get(“$Label.c.labelName”) for the default namespace.
$A.get(“$Label.namespace.labelName”) if your org has a namespace, or to access a label in a managed package.

    clickLabel : function(component, event, helper) {
        var label = $A.get("$Label.c.Message");

Summary field as footer of pageblock table in Visualforce page.

In this post I’ll show, how can we add the summary field or total amount or other information in footer of PageBlockTable or DataTable in Visualforce page.

In the below example I’m using the apex:facet name="footer" tag, to show sum of all the opportunity line items of an Opportunity in footer of PageBlockTable.

<apex:page standardController="Opportunity">    
    <apex:pageBlock title="{!Opportunity.Name}">    
        <apex:pageblocktable value="{!Opportunity.OpportunityLineItems}" var="item">
            <apex:column value="{!item.PricebookEntry.Name}"/>
            <apex:column value="{!item.ServiceDate}"/>
            <apex:column value="{!item.Quantity}"/>
            <apex:column value="{!item.UnitPrice}">
                <apex:facet name="footer">
                    <apex:outputText value="Total:" style="float: right;"/>
            <apex:column value="{!item.TotalPrice}">
                <apex:facet name="footer">