0

I'm creating a Appexchange product. Where I have developed everything using developer org and now for packaging and to submit for security review I'm using another developer org where I have created namespace. So once I deploy all the code and metadata from one org to namespace org. All the apex classes , VF page, lighting components gets prefix with namespace defined.

The problem I'm facing is that. I have used application event in many of my lighting components. Where in this app exchange product I'm building will be available in both classic and lighting version. So the lighting components which I have built. I'm using the same thing in classic also but referencing through VF page. But the problem is application event works fine in lightning environment but in classic environment this application event is not working ?

Any help on this would be a great help.

Lightning component:

<aura:registerEvent name="StoreTypeSubTypeMapEvt" type="c:StoreTypeSubTypeMapEvt"/>

Controller code :

var appEvent = $A.get("e.c:StoreTypeSubTypeMapEvt");
debugger;
appEvent.setParams({"typeSubTypeMap" : component.get("v.typeSubTypeMap")});
appEvent.fire();

So once the name space is created Controller code looks like below

Controller code with Namespace:

var appEvent = $A.get("e.NameSpaceVal:StoreTypeSubTypeMapEvt");
debugger;
appEvent.setParams({"typeSubTypeMap" : component.get("v.typeSubTypeMap")});
appEvent.fire();

This is working fine in lightning environment but in classic environment its not working. Its throwing below error

This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read property 'setParams' of undefined] Callback failed: apex://TypeSubtypeController/ACTION$getTypeAndSubTypeMap Failing descriptor: {c:iContractTypeSubtypeComponent}

  • You probably do not have to hardcode a namespace while firing an event, $A.get("e.NameSpaceVal:StoreTypeSubTypeMapEvt") should work just fine? Does that not work? – Raul Jan 29 at 14:58
  • No Raul, That works fine in Lightning environment. But the same component is not working in classic environment. Without namespace having just $A.get("e.c:StoreTypeSubTypeMapEvt") works in the org where namespace is not defined. But in the org where namespace is created either "e.c.StoreTypeSubTypeMapEvt" / "e.c.NameSpaceVal.StoreTypeSubTypeMapEvt" wont work for classic. – Jayanth B Jan 29 at 15:38
  • Application event only works inside a lightning container or Lightning experience. I suppose you're using Lightning out in Visualforce to expose your lightning application; you need to listen to the event and perform necessary action in visualforce. – Raul Jan 29 at 17:07
  • Hi Raul, Even i though of the same first.but application event works in classic mode when used though VF page. But the same wont work with namespace. Without nameSpace it works fine. – Jayanth B Jan 30 at 5:41
0

In application event you need to specify access=GLOBAL to fire an application event in namespaced org.

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.