3

In my case, I am deveoping a managed package. My customers download my managed package. And I want my customers can add their own lightning component to the managed package.

I am planning that I can get customers lightning component name via custom settings. And, I want to add component dynamically to managed package.

Is it possible?

1 Answer 1

6

The managed package can't be updated in the subscriber's org, but you can gain access to subscriber components via $A.createComponents. The caveat, of course, is that the access of the component in question must be global in order for you to successfully gain access to it.

({
  someControllerMethod: function(component, event, helper) {
    $A.createComponents([["c:someComponent", {}]], $A.getCallback(function(createdComps) {
      component.set("v.body", createdComps);
    }));
  }
})

Where c:someComponent will be gained from your custom setting, label, or whatever you decide to use.

2
  • Thank you @sfdcfox, I can add org's lightning components to managed package dynamically. However, I see that even if I set attributes, the component is displayed without attribute values. Why does it happen? I am creating ui components with attributes, they works perfectly. But for this component I cannot set attributes on dynamically created.
    – efirat
    Commented Dec 26, 2017 at 6:22
  • 1
    @efirat The attributes must also have access="global" or they cannot be set.
    – sfdcfox
    Commented Dec 26, 2017 at 6:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .