May 31, 2021

Can't Make A Callout to Own Salesforce from Lightning Component

 Making API Calls from Apex(☑️ )/Java Script(❎)

  • We can Make API calls from an Apex controller. You can’t make Salesforce API calls from JavaScript code.
  • For security reasons, the Lightning Component framework places restrictions on making API calls from JavaScript code. To call third-party APIs from your component’s JavaScript code, add the API endpoint as a CSP Trusted Site.
  • To call Salesforce APIs, make the API calls from your component’s Apex controller. Use a named credential to authenticate to Salesforce.

Note:

    By security policy, sessions created by Lightning components aren’t enabled for API access. This prevents even your Apex code from making API calls to Salesforce. Using a named credential for specific API calls allows you to carefully and selectively bypass this security restriction.
    The restrictions on API-enabled sessions aren’t accidental. Carefully review any code that uses a named credential to ensure you’re not creating a vulnerability.

May 23, 2021

Summer ’21

 

LWC Quick Actions:

    We can now use Lightning Web Components as Quick Actions! While you can currently do this with Aura Components, this new implementation brings some great new features! First off, there are TWO different types of LWC Quick Actions 

  1. Screen Actions and
  2. Headless Actions. 

Referece Link : Click Here

 

Aura Components in the ui Namespace Are Deprecated

  • Salesforce is ending support for Aura components in the ui namespace on May 1, 2021
  • Migrate to Lightning Web Components (LWC) whenever possibl
  • Replace the deprecated components with their counterparts in the lightning namespace.
  • These components are faster, more efficient, and they implement Lightning Design System styling out-of-the-box.

Example:

ui:actionMenuItem

Use lightning:menuItem with lightning:buttonMenu instead.

When migrating to Lightning Web Components, use lightning-menu-item with lightning-button-menu.

ui:inputText

Use lightning:input with text type instead.

When migrating to Lightning Web Components, use lightning-input with text type. 

 

Referece Link : Click Here 



May 20, 2021

USER PASSWORD FLOW

 

 USER PASSWORD FLOW


 API Authentication mechanism for Salesforce System 

Salesforce APIs are authenticated. These APIs are accessible through the OAuth 2.0 Password authentication flow. 

  • {Domain} maybe
    • Test.salesforce.com --> Sandbox
    • Login.salesforce.com --> production


API URL:
https://{Domain}/services/oauth2/token 

Access Mechanism: OAuth2.0. 

Request Method: POST 

Request from third party : 

Request from Third Party System


Attribute Name 

Value

Type

grant_type 

password (should be as it is)

String

username 

TBD

String

password 

TBD (if required append Security Token)

String

client_id 

TBD

String

client_secret 

TBD

String



Success Response from Salesforce: 

Response from Salesforce


Attribute Name 

Description 

Type

access_token

Access token that acts as a session ID that the application uses for making requests. This token should be protected as though it were user credentials.

String

signature 

Base64-encoded HMAC-SHA256 signature

String

issued_at

When the signature was created, represented as the number of seconds since the Unix epoch (00:00:00 UTC on 1 January 1970)

String

instance_url 

Identifies the Salesforce instance to which API calls are sent 

String

id 

Identity URL

String



Error Response from Salesforce:

Response from Salesforce


Attribute Name 

Description 

Type

error

Error code (unsupported_response_type/ 

invalid_client_id/ invalid_request/ 

invalid_client_credentials / invalid_grant/ 

inactive_user/ inactive_org/ rate_limit_exceeded)

String

error 

description 

Error Description

String


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.