function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sumit dsumit d 

Getting fields from Apex to Aura component

Hi All,
          I have an Aura component in which i have a child component i want to pass the value from Apex to this component. how can i do this?
my Aura and Apex controller is given below:-

 public class CommEventsController {
    public static String getZoneId() {
        Set<Id> contactIds = new Set<Id>();
        Map< Id, User> mapOfContactIdToUser = new Map<Id,User>();
        Map<Id, Forum_Members__c> mapOfForumIdToMembers = new Map<Id,Forum_Members__c>();
        for( User ur : [ SELECT Id, ContactId 
                        FROM User 
                        WHERE Id =: userinfo.getUserId() ] )
            if( ur.ContactId != null ){
                mapOfContactIdToUser.put( ur.ContactId , ur );
        for( Forum_Members__c fm : [ SELECT Id, Member__c,Forum__c
                                    FROM Forum_Members__c 
                                    WHERE Member__c IN: mapOfContactIdToUser.KeySet() ] )
            if( fm.Member__c != null ){
        List<Forum__c> listOfForum = New List<Forum__c>();
        listOfForum = [Select AC_Events_Zone__c from Forum__c where Id IN: mapOfForumIdToMembers.keySet()];
        String zoneId = listOfForum.Size()>0?listOfForum[0].AC_Events_Zone__c:Null;
        return zoneId;
Aura component:- 
<aura:component controller="CommEventsController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="zoneId" type="String" />
    <bre:DatePicker zoneId="{!v.zoneId}"  />
    myAction : function(component, event, helper) {
        var action = component.get("c.getZoneId");
I am getting the zoneId in Apex controller and i want to pass it to the component. how can i do it ?
Can anyone help?
PriyaPriya (Salesforce Developers) 
Hi Sumit,

Can you please use below to get value from controller to component.
action.setParams({ "myString" : myAttribute });

Hope this is helpful!