Think. Build. Salesforce Solutions.

Salesforce Consulting Services across Salesforce Clouds & Across App Lifecycles

Blog

Communication Between Lightning Component in Community Cloud

By |2021-02-26T08:42:56+00:00February 26th, 2021|

Introduction to Community Cloud- Community Cloud is a digital platform of Salesforce. It is used to connect with your Partners, Customer, and Employees of your Organization.

Introduction to Community Cloud

License Types – Below is the list of License Type:

Introduction to Community Cloud

Communication in Lightning Component- When we work in the Community, we use multiple Lightning Components and many time it becomes need to communicate between the two or many lightning component which is published in the community. Unlike CRM lightning component where we use to create an event whether it is application event and platform event and then we have to make one component as child component where we have to register the event by <aura:registerevent > and In Parent Component we have to handle the Event by using <aura:handler> also we need to include JS Controller of child and parent component which is a too long process for basic communication between the components.

So, the communication between the two lightning components in the Community is too simple. Here we do not need to create any kind of event and do not need to make any component as Parent and Child. In Community, it treats two components or many components as a friend with No Difference.

Let’s say you want to send the value of Name and Email entered in the First Component ‘Community_LC_cmp1’ and want to send the above value to Second Component ‘Community_LC_cmp2’

What you only need to do just refer the Community_LC_cmp2 in Community_LC_cmp1 like below:

Community_LC_Cmp1 Component:

<aura:component controller =’anycontrollerif needed’ implements=”force:appHostable, flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId, forceCommunity:availableForAllPageTypes,forcelightningQuickAction” acess=”global”>

<aura:attribute name=”uName” type=”String” />
<aura:attribute name=”email” type=”String” />
<aura:attribute name=”checkDetail” type=”Boolean” default=”false” />
<div class=”slds-col slds-size_1-of-1 slds-p-around_small slds-p-top_none”>
<div class=”slds-grid slds-wrap”>
<lightning:input aura:id=”userName” type=”String” label= “Enter Name” value=”{!v.uName}” />
<lightning:input aura:id=”userEmail” type=”email” label= “Enter Email” value=”{!v.email}” />
<lightning:button class=”send” variant=”brand” onclick=”{!c.sendDetail}” > Check </lightning:button>
<aura:if isTrue=”{!v. checkDetail }” >
<c: Community_LC_Cmp2 userName=”{!v.uName}” userEmail=”{!v.email}” />
<!—setting the attribute of component 2 –>
</aura:if>
Community_LC_Cmp1Controller.js
({
sendDetail : function(component, event, helper) {
component.set(“v.checkDetail”,true);

}
})

Thus, Setting the <aura:attribute> of the second lightning component is too simple and easy just we need to User <c:componentName attribute=”attributeValue”> and we can the attribute value anywhere like in DML OR UI.

So, Working in the Community is too easy and features of salesforce Community are very useful for collaboration with your Customers which is very important for the exponential growth of the business.

If your Salesforce community is not set up till now so kindly reach out the Mirketa to make it set up and enjoy the benefits of Salesforce Community and Grow your Business.

Thank you

Leave A Comment