Sunday, 21 February 2021

Access Custom Metadata Type Records Using Static Methods

Hi,


We were using SOQL query for retrieving "Custom Meta Data Type" Records. 

Now We can Use the Apex getAll(), getInstance(recordId), getInstance(qualifiedApiName), and getInstance(developerName) methods to retrieve information from custom metadata type records faster. These methods don’t rely on the SOQL engine and return the sObject details directly from the call.

The following example uses the getAll() method. The custom metadata type named "EndpointUrlSettings__mdt" has a field called Endpoint__c.

List<EndpointUrlSettings__mdt> endpointUrlList = EndpointUrlSettings__mdt.getall().values();

for(EndpointUrlSettings__mdt endointObj:endpointUrlList){

    System.debug('End point:'+endointObj.Endpoint__c);    

}

System.debug('Record values based on DeveloperName:'+EndpointUrlSettings__mdt.getInstance('Field_Meta_Data'));

Here "Field_Meta_Data" is a developername value of a record in the above Custom Meta Data Type.


Reference:

https://help.salesforce.com/articleView?id=sf.custommetadatatypes_relationships.htm&type=5

https://releasenotes.docs.salesforce.com/en-us/spring21/release-notes/rn_forcecom_dev_static_accessor.htm?edition=&impact=

Define Localized Component Labels and Attribute Values on Lightning Pages Using Custom Labels

 Hi,

Here we are going to learn how to define Localized Component Labels and Attribute Values on Lightning Pages Using Custom Labels.

With Localization Support in App Builder, when you specify a custom label in the Lightning App Builder, you can use {!$Label.customLabelName} to help define the label’s value.

On a Lightning page, custom Tabs component and other component attribute values aren’t localized when they’re entered as plain text in the Lightning App Builder. 

Eg: If we have an org whose default language is English and our Lightning page has a Tabs component with three custom tabs that we named Cars, Trucks, and Planes, the non-English users in our org see those plain text tab label values as Cars, Trucks, and Planes when they view the page. The tab label values aren’t translated into your users’ languages.

However, configuring custom label values in the Lightning App Builder using the {!$Label.customLabelName} expression lets users see labels in their chosen language, if we create a translation for that label in their language.




The {!$Label.customLabelName} expression works with every custom label we create in Setup using the custom label feature. 

The text we define in the Value field for our custom label appears as the label value when the component renders on a Lightning page. 

And, if we create a translated value for the label, users using that language in our org see the translated value.

The {!$Label.customLabelName} expression isn’t limited to use for component or tab labels. 

we can also use it to provide a translated value for any component attribute of type string or rich text.


Reference:

https://help.salesforce.com/articleView?id=sf.lightning_page_components_use_expressions_for_labels.htm&type=5

https://releasenotes.docs.salesforce.com/en-us/spring21/release-notes/rn_forcecom_lab_expressions_in_comp_labels.htm


Solution for System.HttpResponse[Status=Moved Temporarily, StatusCode=302]

 Hi ,

We get different different kinds of  response Status and Status codes when we do callouts .

One of the Http Response is 

System.HttpResponse[Status=Moved Temporarily, StatusCode=302]

To avoid this we have to follow the code snippet below.


System.HttpResponse[Status=Moved Temporarily, StatusCode=302]


 while (res.getStatusCode() == 302) {

            req.setEndpoint(res.getHeader('Location'));

            res = new Http().send(req);

 }

Usually when we get status code as 302 , the server will also provide the new location.  We need to extract that from the headers and request it as shown above.



Monday, 15 February 2021

Managed Package Installation Issue (You can’t specify version for namespace sf_com_apps because this namespace is not installed to your organization)

 Hi,

When we face the following issue while installing  any package then install the "sf_com_apps".

Problem:1. You can’t specify version for namespace sf_com_apps because this namespace is not installed to your organization.
: You can’t specify version for namespace sf_com_apps because this namespace is not installed to your organization.

You can install "sf_com_apps" in two way mainly.

  1. Login to workbench from your Salesforce instance then Salesforce installs "sf_com_apps" automatically in few mins
  2. Install the package using the following package URL: https://login.salesforce.com/packaging/installPackage.apexp?p0=04t30000001DUvr



Sunday, 7 February 2021

How Set Pre-Chat Form Fields to Automatically Populate when Customers Log In (Snap-In)

 Hi,

The following sample code for embedded_svc.settings.prepopulatedPrechatFields populates the First Name, Last Name, Email, and Subject fields in the pre-chat form.

embedded_svc.settings.prepopulatedPrechatFields = {

    FirstName: “John”,

    LastName: “Doe”,

    Email: “john.doe@salesforce.com”,

    Subject: “Hello”

};

Note: It should be added before "embedded_svc.init"
Reference:
https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_populate_prechat.htm

How to route chat to different Chat buttons (different teams) based on input given on Pre-Chat form (Snap-In)

Hi , 
Here we are going to learn how can we route chat to different Chat buttons based on input given on Pre-Chat form when we implement the same with the help of Snap-In (Embedded Service Deployment)

It helps to route customers to specific Agents based on their selection on Pre-Chat form.

To achieve this we simply need to follow the following snippet.

 embedded_svc.settings.directToButtonRouting = function(prechatFormData) {
            // Dynamically changes the button ID based on what the visitor enters in the pre-chat form.
            // Returns a valid button ID.           
            if(prechatFormData[2].value=='Service')
                return '573xxxxxxxxxxxx';  
            else if(prechatFormData[2].value=='Sales')
return '573xxxxxxxxxxxx';
};

here "prechatFormData" helps to get the values given in Pre-chat form. We have to get the values based on index of each pre chat form field. Index starts with '0' in sequence from Left to Right always.

In the above example at the index of "2" user  is selecting department type as "Sales" or "Service" based on the selected value we are able to route as as shown above.

Note: We have to write the above snippet before "embedded_svc.init"

Reference:
https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_snippet_settings_file.htm

How to pass values from Pre chat form fields to Chat Transcript Fields in Snap-In chat (Embedded Service Deployment )

 Hi ,

Here we are going to learn how can we map Pre-Chat form fields with Chat Transcript object fields when we enable chat with the help of "Snap-In (Embedded Service Deployment)".

When we want to map Pre-Chat form fields with "Chat Transcript" object fields we have to map 

Pre-Chat form field Label with "Chat Transcript" object Field Api Name as shown below under "embedded_svc.settings.extraPrechatFormDetails"

embedded_svc.settings.extraPrechatFormDetails = [{

          "label":"First Name",  

          "transcriptFields": ["FirstName__c"]

},{

          "label":"Last Name", 

          "transcriptFields": ["LastName__c"]

},{

          "label":"Email", 

          "transcriptFields": ["Email__c"]

},{

          "label":"Service Type", 

          "transcriptFields": ["Service Type__c"]

}];

Here "label" represents the label of field on Pre-Chat form and "transcriptFields" represents "Chat Transcript" field API Name to map or to store once chat initiated and chat transcript  record is created.

So in our case "First Name" from "Pre-Chat" form will be stored to "FirstName__c" field on Chat Transcript object ,"Last Name" from "Pre-Chat" form will be stored to "LastName__c" fied on Chat Transcript object etc.,

Note: We have to write the above snippet before "embedded_svc.init"

Reference:

https://help.salesforce.com/articleView?id=000349323&language=en_US&mode=1&type=1

https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_snippet_settings_file.htm



What’s the difference between Einstein Article Recommendations and Suggested Articles?

How Does Einstein Article Recommendations Work? Einstein Article Recommendations helps support agents resolve customer cases efficiently by ...