Friday, March 16, 2018

Salesforce Lightning - inter namespace component communication



There is a challenge to integrate lightning components from different managed packages. There raised a question "Are the communication between the components from different namespace is possible ? "

As per my understanding, I confirmed yes;  but others are not satisfied on that. So we have raised a case for Salesforce support and  described our problem to them. They confirmed that inter namespace communication is not possible in locker service.

Since I have still doubted on that, I done a POC with different namespaces.

I have created a parent component with two attributes in one org (namespace1) and created a child component in another org (namespace2). I have integrated both of them with Javascript.  The two packages are created from both of the orgs and installed in a 3rd org.

In the 3rd org, I can success fully run the application by passing attribute values from parent component (namespace1) to child component (namespace2) also using the events I passed the data back from child to parent componet.


So I can confirm, the communication between lightning components which are in different namespace is possible, rather than the Salesforce support.

Its my experience !!!





Thursday, March 15, 2018

Salesforce Lightning : Dynamic Custom labels in lightning components

Custom labels are used in Salesforce to present the information which are not available in database not part of data records. For eg: the page headings, button labels, help text etc... The custom labels gives an option for developers to present multilingual information  based the end used language. The mail application areas of custom labels are the Visualforce pages & Lightning components.


Custom labels in lightning components 


The custom labels are included in Lightning components as :
  • {!$Label.c.labelName} for the default namespace
  • {!$Label.namespace.labelName} to access a label in a managed package
Else we can use the javascript method :
  • $A.get("$Label.c.labelName")
  • $A.get("$Label.namespace.labelName")

Dynamic Custom labels in lightning components


In some situations  we have to dynamically include the Custom labels on the go.  ie we can only be able to determine the label name on the run time.  The below component will help to get the dynanic label values on the run time