1

I have defined a component event like below to carry list of Brokers.

<aura:event type="COMPONENT">
    <aura:attribute name="data" type="Broker__c[]"/>
</aura:event>

From the controller method, I am setting the parameter on the event like below:

event.setParams({
    "data": component.get('v.selectedBrokers')
});
event.fire();

The attribute is defined as below:

<aura:attribute name="selectedBrokers" type="Broker__c[]" />

But while trying to access the value in parent component, the value is coming as undefined.

WARNING: Unsupported [object Object] method: Symbol(Symbol.toPrimitive). Returning undefined
[object Object]

My question is whether its possible to pass list of sObjects during event propagation.

  • Broker__c[] is not Account[]. I'd expect things to break. – sfdcfox Jul 17 '17 at 16:52
  • Hi. That was typo error. I have edited my question. I am not using Account object, only Broker. – snl Jul 17 '17 at 17:07
  • Did you register the event in the component? i see a warning and not an error, would be good to see the complete component/event/controller package to understand how you are passing data to the event attribute – Rao Jul 17 '17 at 18:24
  • Please share entire component code so we can see where the problem is – Itai Shmida Jul 18 '17 at 4:42
1

To answer your question, Yes, arrays can be passed as event attribute within lightning components framework.

You probably need to look elsewhere for possible cause of error. A good test will be to print the value of list in console logs, before passing them to event.

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.