Wednesday, 28 July 2021

Simple Lightning Component with Wrapper Class

 Hi,

Here we are going to learn how to capture or display the wrapper result with a simple example.

When we want to access the wrapper properties we have to make sure that properties with "@Auraenabled" annotation.

Eg: 

Apex Class : 

public with sharing class WrapExample {
    public class Wrappercls{
        @Auraenabled
        public String firstName{get;set;}
        @Auraenabled
        public String lastName{get;set;}    
    }
    @Auraenabled
    public static Wrappercls getWrapperDetail(){
        Wrappercls wrapObn = new Wrappercls();
        wrapObn.firstName'Navarshi';
        wrapObn.lastName = 'Malem';
        return wrapObn;
    }
}


Aura Component:

<aura:component controller="WrapExample" 
    implements="flexipage:availableForAllPageTypes">
    <aura:attribute name="wrapObj" type="Object" />
    <aura:handler name="init" value="{!this}" action="{!c.retrieveWrapRecord}" />
    <lightning:card title="Wrapper Record Detail" iconName="utility:connected_apps">
        <p class="slds-p-horizontal_small">
        <h1><b>First Name : </b>{!v.wrapObj.firstName}</h1>
        <h1><b>Last Name : </b>{!v.wrapObj.lastName}</h1>
        </p>
    </lightning:card>
</aura:component>

Component Controller:

({
    retrieveWrapRecord : function(componenteventhelper) {
        var action = component.get("c.getWrapperDetail");
        action.setCallback(thisfunction(data) {
            component.set("v.wrapObj"data.getReturnValue());
        });
        $A.enqueueAction(action);
    }
})


Reference : 

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_apex_create.htm




Monday, 26 July 2021

Auto Populate Record Type,other fields and navigate to create page

 Hi,

The record type Id field is case-sensitive when we want to auto-populate with record type.

Sample Example:

var recTypeId = '012XXXXXXXX';

var createContact= $A.get("e.force:createRecord");

createContact.setParams({

"entityApiName": 'Contact',

"recordTypeId":recTypeId,

"defaultFieldValues": {                            

'LastName':'balaji',

'FirstName':'malem'

}

});

createContact.fire();

Note:

Always add recordTypeId before defaultFieldValues as above.


Sunday, 4 July 2021

Custom Metadata Types CLI Commands with Summer 20 Release

Hi,

With Summer 20 release we have very important CLI Commands for Custom Metadata Types

These new commands simplify development and help you build automation and synchronize your source from scratch orgs when working with custom metadata types.

The Salesforce CLI custom metadata types commands are available in v49.0.The Salesforce CLI custom metadata types commands are available in v49.0.

  • sfdx force:cmdt:create Creates a new custom metadata type in the current project.
  • sfdx force:cmdt:field:create Generates a custom metadata field based on the field type provided.
  • sfdx force:cmdt:generate Generates a custom metadata type and all its records for the provided sObject.
  • sfdx force:cmdt:record:create Creates a new record for a given custom metadata type in the current project.
  • sfdx force:cmdt:record:insert Creates new custom metadata type records from a CSV file.



EXAMPLE Insert records into an existing custom metadata type from a CSV file.

Create a CSV file and provide the API name of the custom metadata type in the insert command. For example,

NameCountryCode__cCountryName__c
AustraliaAUAustralia
BrazilBZBrazil
CanadaCACanada
sfdx force:cmdt:record:insert 
-f ~/Downloads/CMT_CSV\ -\ sfdx\ force_cmdt_record_insert\ Country\ Data\ -\ CMT_country.csv -t CmdtCountry

 


Reference:

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

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


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 ...