5

If we have a lightning component, which is a part of managed package, is possible somehow purely from js code to figure out current namespace, i.e. without sending additional request to the server? I know how to do this in apex, but now I'm interested in js solution.

Thanks in advance

5

I thought this would not work but it seems to in one of my development org with the component bundle version set to 40.0 (so locker should be enabled)

console.log(component.getConcreteComponent().getDef().getDescriptor().getNamespace());

Which outputs the namespace for the component. No idea if it will continue to work or is scheduled to be removed so use at your own risk

This does throw an error

console.log(component.getDef().getDescriptor().getNamespace());
  • for me this works perfectly! – Uwe Heim Apr 26 '19 at 17:14
4

How about this

component.getType().split(':')[0];

If no namespace it will return "c".

2

I am afraid that this is not possible since it has been possible to query the namespace of the organisation only after the Spring'16 release. There are no global value providers for this in lightning.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.