Apr 19, 2021

ReUsable Schema Snippets


          Get Object from Record Id:

Id  recordId = '100xxxxxxxxxxxxabc';

Schema.DescribeSObjectResult objectDescribe = recordId.getSobjectType().getDescribe();

String objectName = objectDescribe.getName();


Get Record Type Id Dynamically


          Get Record Type Id by  Record Type Label:

String recordTypeLabel='Parent Account';

String ObjectAPI='Account';

String accRecordTypeID =
Schema.getGlobalDescribe().get(ObjectAPI).getDescribe().getRecordTypeInfosByName().
get(recordTypeLabel).getRecordTypeId();


       Get Record Type Id by  Record Type Developer Name:

String recordTypeDeveloperName='Parent_Account';

String ObjectAPI='Account';

String accRecordTypeID =
Schema.getGlobalDescribe().get(ObjectAPI).getDescribe().getRecordTypeInfosByDeveloperName().get(recordTypeDeveloperName).getRecordTypeId();

 


Get Field Type Dynamically

 

GET Field Type Dynamically 

String objectAPIName = 'Account';
String fieldAPIName = 'Name';

SObjectType r = ( (SObject) Type.forName('Schema.'+objectAPIName).newInstance())).
getSObjectType();

 DescribeSObjectResult d = r.getDescribe();

System.debug(d.fields.getMap().get(fieldAPIName).getDescribe().getType());

 


Apr 6, 2021

ReUsable Apex Snippets

Query All Fields from Specific Object

public static String AllFields(String ObjectName) {

List<String> fields = new List<String>(

 Schema.getGlobalDescribe().get(ObjectName).getDescribe().fields.getMap().keySet()

);

String query  = 'SELECT '+String.join(fields, ',')+' FROM '+ObjectName;


return query;

    }



Apr 4, 2021

Reusable Lightning Snippets

Spinner

<!-- spinner Start  -->

    <aura:attribute name="isLoading" type="Boolean" default="false" />

  

<aura:if isTrue="{!v.isLoading}">

        <div class="demo-only" style="height:6rem">

            <div class="slds-spinner_container">

                <div role="status" class="slds-spinner slds-spinner_medium slds-spinner_brand">

                    <span class="slds-assistive-text">Loading</span>

                    <div class="slds-spinner__dot-a"></div>

                    <div class="slds-spinner__dot-b"></div>

                </div>

            </div>

        </div>

    </aura:if>

    <!-- spinner end  -->


Model pop up

  <!-- Model pop Start  -->

    <section aria-describedby="modal-content-id-1" aria-labelledby="modal-heading-01" aria-modal="true" class="slds-modal slds-fade-in-open slds-modal_medium" role="dialog" tabindex="-1">

        <div class="slds-modal__container">

            <header class="slds-modal__header">

                <lightning:buttonicon alternativetext="close" class="slds-modal__close" iconname="utility:close" onclick="{! c.hideModel }" variant="bare-inverse">

                <h2 class="slds-modal__title slds-hyphenate" id="modal-heading-01">Modal header</h2>

            </lightning:buttonicon></header>

            <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">

                <lightning:card footer="Card Footer" title="Hello">

                    <aura:set attribute="actions">

                        <lightning:button label="New">

                    </lightning:button></aura:set>

                    <p class="slds-p-horizontal_small">

                        Card Body (custom component)

                    </p>

                </lightning:card>

            </div>

            <footer class="slds-modal__footer">

                <button class="slds-button slds-button_neutral">Cancel</button>

                <button class="slds-button slds-button_brand">Save</button>

            </footer>

        </div>

    </section>

    <div class="slds-backdrop slds-backdrop_open"></div>  

     <!-- Model pop End  -->



Common Helper methods

({

    actionMethod : function(cmp,action){

        return new Promise(function (resolve, reject) {

            action.setCallback(this, function (response) {

                //alert(response.getState());

                if (response.getState() === 'SUCCESS') {

                    resolve(response.getReturnValue());

                } else if(response.getState() === 'ERROR') {

                    reject(response.getError());

                }

            });

            // if an action isn't getting called you probably missed this line

            $A.enqueueAction(action);

        });

    },

    showToast : function(type, title, message, duration, mode, key) {

        var toastEvent = $A.get("e.force:showToast");

        toastEvent.setParams({

            "title": title,

            "message": message,

            "type": type,

            "duration": duration,

            "mode": mode,

            "key": key

        });

        toastEvent.fire();

    },

})



Close Quick Action

                 $A.get('e.force:refreshView').fire();

                var dismissActionPanel = $A.get('e.force:closeQuickAction');

                dismissActionPanel.fire();



Mar 21, 2021

CPQ Product Bundle

 CPQ Product Bundle 

Bundle:

  • A bundle is simply a group of products we know should be sold together ( A bunch of products sold together as a set. ) or  A bundle is a product with optional features or components that you want to include on a single quote line.
  • A bundle product contains several records.

  • A bundle parent: The parent product is the bundle itself.

  • Options: These products in the bundle contribute to the bundle price. You can consider these children of the bundle parent. An option doesn’t contribute to the bundle price if you select its Bundled checkbox.

  • Features: A feature is a group of options. You can use the Min Options and Max Options fields to define selection restrictions for objects in the same feature, such as “pick one or more” or “pick 3 of 5.”. or A feature is a group of product options within a bundle. Use features if you want to organize options into set groups, such as hardware and software.

  • Option constraints: Use constraints to control how users select options together.

  • Configuration attribute: A field and picklist shown above or below the list of product options. This field targets all options containing the same field and applies its value to all those fields.
  • There are three types of bundles. 
    • Static bundle:  These bundles always have the same products together, in the same quantities, with no changes allowed
    • Configurable bundle: This bundle can be customized to your liking, with some limits to prevent impossible configurations.
    • Nested bundle: This is a bundle inside another bundle.   

 

Control When Sales Reps Can Configure Bundles

  •  Change a product’s configuration event, Configuration Type  fields to control when Salesforce CPQ allows sales reps to configure a bundle.

  • Configuration Event field With the following values.

    • Always: Salesforce CPQ opens the configurator when the sales rep adds the bundle product. The quote line item always displays the configuration link as well.

    • Add: Salesforce CPQ opens the configurator when the sales rep adds the bundle product. After initial configuration, the quote line item doesn’t display the configuration link.

    • Edit: Salesforce CPQ doesn’t open the configurator when the sales rep adds the bundle product. However, they can select the configuration link on the quote line. This value saves time if you have a bundle that always or frequently uses its default configuration.
  • Configuration Type the following values.

    • Allowed: The sales rep can configure the bundle at any point. Since they’re not required to configure it, they can leave the initial configuration page without making any changes.

    • Disabled: Sales reps can’t configure the bundle. Salesforce CPQ doesn’t prompt them to choose options after adding the bundle product. And it doesn’t show a Configure link next to the bundle’s quote line item. Use this value when your bundle automatically selects options.

    • Required: The sales rep can’t leave the initial configuration page until they choose at least one product option.


  • Global attributes. Global attributes are reusable, so admins can attach them to as many options as they’d like (even across multiple bundles)

  • Configuration attributes: cannot be reused in another bundle. Configuration attributes have a few additional behaviors we can set up to make them easier to use, which we can see throughout this project. Sometimes configuration attributes are found in specific bundle features.

    • it’s important to understand that configuration attributes are not actually fields, but are visible manifestations of fields.

    • To create a new configuration attribute you’ll go through the three steps

      • Create a field on the Product Option object.

      • Add the API name of the field to the Target Field field on the Configuration Attribute object.

      • Create a configuration attribute record on the bundle product.

  • Both configuration and global attributes are meant to gather information you can use later in the sales and fulfillment process.

  •  Global attributes are like configuration attributes, with a few important distinctions.

    DifferencesConfiguration AttributesGlobal Attributes

    Appearance

    Visible above, below, or inside features.

    Visible in an expandable drawer on the option.

    Reusability

    May be related to a single bundle.

    May be related to as many options as you’d like, even across bundles.

    Construction

    Requires only one record related to the product.

    Requires four records across four objects.

    Behavior

    May be configured to use a default value, show or hide picklist values, be required, and more.

    Currently, cannot be configured with any of the special behaviors such as default values.

 

  • Attribute sets are collections of global attributes that have something in common. 

  • Global attributes are related to attribute sets through a junction object called an attribute item, which has lookups to each of the other objects.

    Relationship diagram including global attribute, attribute item, and attribute set

  • This kind of relationship allows you to create more than one attribute set from the same collection of global attributes.

  • An attribute item does more than just connect a global attribute to an attribute set. It also determines which should appear first from left to right 

  • Product Attribute Set :To associate the Attribute set to both Product band product optionsWe need to use another junction object named Product Attribute Set.

    Diagram relating attribute set, product attribute set, and product option


Mapping Custom Fields Between Objects

  • Certain pairs of CPQ objects pass custom field values from the first object to the second object when the second object is created. The values pass if the custom fields are editable, have matching field types, and have matching API names. We call these field pairs “twin fields.


  • Reference Link Here

Mar 16, 2021

CPQ

 CPQ

  • CPQ stands for configure, price, and quote.
    • What products does the customer want to buy (configure)?
    • How much do those products cost (price)? 
    • How can we give the customer details about the sale (quote)?

  • Salesforce CPQ, a native Salesforce app that helps you and your team close deals even faster.
  • Salesforce CPQ makes the process much easier for you and your team. And it helps you produce a quality quote that’s complete and accurate and that looks professional.

What Does CPQ Actually Do?

    • With Salesforce CPQ, you and your sales team can create quotes quickly, with minimal effort and minimal error. 
    • Here’s a little rhyme to introduce you to the wonders of CPQ:
    • The C is for configure. You pick out what they’ll buy.
    • The P is for price. We add it up, easy as pie.
    • The Q is for quote: A nice PDF for you.

A quote is both the document you give the customer and the electronic record of quote data. Your opportunity is where you go to create a new quote. You can create many quotes on that opportunity, but only one can be your primary quote.



 

Salesforce CPQ simplifies product selection so you create quotes correctly the first time.

Sometimes you have to sell products as a package because the component products depend on each other. With Salesforce CPQ, your Salesforce admin can group products in a set and enforce rules to ensure the set is complete and accurate. These sets are called bundles. 













Price Rules

There are four kinds of product rules:

  • validation rules
  • selection rules
  • filter rules, and

  • alert rules.


Validation Rules

Validation rules confirm that a quote’s product combinations or quote line field values match predetermined conditions.
Selection Rules

Set up rules to automatically add, remove, hide, enable, or disable options in a bundle.
Filter Rules

Prefilter the products that are available to add to a bundle.
Alert Rules

Guide and inform through messages during configuration or pricing.

Salesforce CPQ price rules help control quoting and optimize sales. Price rules automate price calculations and update quote line fields.


Salesforce CPQ is a solution used by sales, it really does affect how a company as a whole goes to market and delivers service to customers. To sum it up:

    • Product and pricing rules help product and pricing teams establish value and determine how to better package what you’re selling.

    • Advanced approvals enable sales, operations, and legal teams to work better together to ensure there are appropriate checks and balances.

    • Advanced order management helps post-sales teams (think services and partners) deliver as expected and on time.

    • With all this data centralized, and with how Salesforce CPQ treats time, these teams can keep a better eye on the customer and iterate for better execution and delivery.

 



 


Jan 6, 2021

Refer to the Prior Values of the Record That Triggered Your Flow

 Refer to the Prior Values of the Record That Triggered Your Flow


  • We can compare new value , old value by using ISCHANGED  in Process Builder 
  • We can do same thing in Workflow as well
  • but we can't do this comparison in Salesforce Flow
In Spring 21 , we can do this comparison by using {!$Record__Prior}


Reference : https://help.salesforce.com/articleView?id=release-notes.rn_forcecom_flow_fbuilder_prior_values_flow.htm&type=5&release=230 

Jan 4, 2021

Why Use the Aura Components Programming Model?

Aura Components Programming Model


Benefits:

Out-of-the-box Components

      Comes with an out-of-the-box set of components to kick start building apps. You don't have to spend your time optimising your apps for different devices as the components take care of that for you.


Rich Component Ecosystem
Create business-ready components and make them available in the Salesforce app, Lightning Experience, and Communities. Salesforce app users access your components via the navigation menu. Customize Lightning Experience or Communities using drag-and-drop components on a Lightning Page in the Lightning App Builder or using Experience Builder. Additional components are available for your org in the AppExchange. Similarly, you can publish your components and share them with other users.
Fast Development
Empowers teams to work faster with out-of-the-box components that function seamlessly with desktop and mobile devices. Building an app with components facilitates parallel design, improving overall development efficiency.
Components are encapsulated and their internals stay private, while their public shape is visible to consumers of the component. This strong separation gives component authors freedom to change the internal implementation details and insulates component consumers from those changes.
Device-aware and Cross Browser Compatibility
Apps use responsive design and support the latest in browser technology such as HTML5, CSS3, and touch events.

Decorators

 Decorators

Decorators

Decorators are often used in JavaScript to modify the behavior of a property or function.
@api: Marks a field as public. Public properties define the API for a component. An owner component that uses the component in its HTML markup can access the component’s public properties.
All public properties are reactive, which means that the framework observes the property for changes. When the property’s value changes, the framework reacts and rerenders the component.
@track: Tells the framework to observe changes to the properties of an object or to the elements of an array. If a change occurs, the framework rerenders the component.
Prior to Spring ’20, you had to use @track to mark fields (also known as private properties) as reactive. You’re no longer required to do that. Use @track only to tell the framework to observe changes to the properties of an object or to the elements of an array. Some legacy examples may still use @track where it isn’t needed, but that’s OK because using the decorator doesn’t change the functionality or break the code. For more information, see this release note.
@wire: Gives you an easy way to get and bind data from a Salesforce org.

SOQL - Salesforce Object Query Language

SOQL 


 Salesforce’s back-end database uses Oracle

  • SOQL: Salesforce Object Query Language
  • SOQL is used only to perform queries with the SELECT statement. SOQL has no equivalent INSERT, UPDATE, and DELETE statements
  • Data manipulation is handled using a set of methods known as DML (Data Manipulation Language)
  • One big difference you’ll notice right away is that SOQL has no such thing as SELECT *. Because SOQL returns Salesforce data, and that data lives in a multi-tenanted environment where everyone is kind of "sharing the database,” a wildcard character like * is asking for trouble



SOQL has two basic relationship query types that you need to remember:
  • Child-to-parent
  • Parent-to-children

Child-to-parent

  • SELECT c.FirstName, c.LastName, a.Name FROM Account a RIGHT JOIN Contact c ON (c.AccountId = a.Id)

 Parent-to-Children

  • SELECT Name, (Select FirstName, LastName FROM Contacts) FROM Account

SOQL Aggregate Functions

FunctionDescription
AVG()Returns the average value of a numeric field.
COUNT() and
COUNT(fieldName) and
 COUNT_DISTINCT()
Returns the number of rows matching the query criteria.
MIN()Returns the minimum value of a field.
MAX()Returns the maximum value of a field.
SUM()Returns the total sum of a numeric field.

Best Practices:

  • use Filters in SOQL ( Where Clause)

  • use indexed Fields in Where Clause

  • Id
  • Name
  • OwnerId
  • CreatedDate
  • SystemModStamp
  • RecordType
  • Master-Detail
  • Lookup Fields
  • Unique Fields
  • External ID Fields

  • avoid these things

  • Querying for null rows
    • SELECT Id, Name FROM Account WHERE Custom_Field__c = null
  • Negative filter operators
    • SELECT CaseNumber FROM Case WHERE Status !=New
  • Leading wildcards
    • SELECT Id, LastName, FirstName FROM Contact WHERE LastName LIKE ‘%smi%
  • Text fields with comparison operators
    • SELECT AccountId, Amount FROM Opportunity WHERE Order_Number__c > 10

Lightning Flow

 

Lightning Flow


  • Lightning Flow is the name of the product.
    • It is a Salesforce product that encompasses building, managing, and running flows and processes.
  • Process Builder and Flow Builder are the names of the tools.
  • Use Process Builder to make processes; use Flow Builder to make flows.
Process Builder
Process Builder is a point-and-click tool that lets you easily automate if/then business processes and see a graphical representation of your process as you build.

Use Process Builder when you need to start a behind-the-scenes business process automatically. Processes can start when:
  • A record is created
  • A record is updated
  • A platform event occurs
Actions: What the Process Should Do
When a criteria node evaluates to true, the process executes the associated actions or waits to execute them at a scheduled time.
  • Each immediate action is executed as soon as the criteria evaluates to true.
  • Each scheduled action is executed at the specified time, such as 10 days before the record’s close date or 2 days from now. 

Process Builder can:
  • Create records.
  • Update the record that started the process or any related record.
  • Submit that record for approval.
  • Update one or more related records.
  • Send emails using a specified email template.
  • Post to a Chatter feed.
  • Invoke auto-launched flow
  • Invoke Apex class
Process Builder can’t:
  • Post to a community feed.
  • Submit a related record for approval.
  • Delete records(Without Apex)
  • Create a bunch of records and associate them with each other.
  • Perform complex logic.

Flow Builder

Use Flow Builder to:
  • Automate a guided visual experience.
  • Add more functionality for a behind-the-scenes process than is available in Process Builder. Use Flow Builder to build the more complex functionality. Then call the resulting flow from the process.
  • Start a behind-the-scenes business process when a user clicks something, like a button.
For example, when an opportunity is won, your company wants a renewal opportunity to be created automatically. As you see later in this module, you can build parts of that use case as a process, but the rest has to be built in a flow.

screen flows : Needs user Inputs to business Automation
autolaunched flows : Run in the background like a process.Can’t have screens

In Process Builder, you can’t grab the ID of the created record and use it elsewhere. Luckily, you can do that in a flow.

Apex

Use Apex when you need more functionality than is available in Process Builder or Flow Builder. Build the more complex functionality as invocable Apex methods. Then call the resulting Apex as an Apex action in the process or as an Apex action element in the flow.

Approvals isn’t included in Lightning Flow, but it offers a declarative way to automate something that Lightning Flow doesn’t cover