1

I have an Apex method createRecurringEngagements that accepts a Boolean parameter jewishEducator (the last param). I print the parameter in the Apex class but it is always null. I tried accepting jewishEducator as a String instead of a Boolean but that didn't work. I also console.log the jewishEducator value in my aura helper method before calling the apex method, and it correctly prints the value. Why is the parameter always null in the Apex class?

Apex class:

@AuraEnabled
    public static List<Engagement__c> createRecurringEngagements( String engagementTitle , String engagementType , String engagementSubType , String engagementStartDate
            ,String engagementEndDate, String recurrencePattern , String numberOfRecurrences , String recurringFrequency , Id campus, String participants,
            String selectedWeekDay, String selectedWeekNumber, String selectedDayOfMonth, String[] engagerIds, String jewishEducatorString) {

        System.debug('jewishEducator: ' + jewishEducatorString); //always prints null

Aura helper method:

createRecurringEngagements: function(cmp, event){
        let createEngagementsAction = cmp.get('c.createRecurringEngagements');
let createRecur = cmp.find('createRecurringEngagement');
let jewishEducator = createRecur.get('v.newEngagement.Jewish_Educator__c');
        if(jewishEducator === undefined) {
            jewishEducator = false;
        }
jewishEducator = JSON.stringify(jewishEducator);
console.log('final jewishEducator: ' + jewishEducator); //always prints correctly

createEngagementsAction.setParams({
        "engagementTitle": title,
        "engagementStartDate": startDate,
        "engagementEndDate": endDate,
        "engagementType": engType,
        "engagementSubType": subType,
        "recurrencePattern": recPattern,
        "recurringFrequency": recEveryValue,
        "numberOfRecurrences": numberRecur,
        "campusId": campusId,
        "participants": JSON.stringify(contactList),
        "selectedWeekDay": selectedDayOfWeek,
        "selectedWeekNumber": selectedWeekNumber,
        "selectedDayOfMonth": selectedDayOfMonth,
        "engagerIds": engagerIds,
        "jewishEducatorString:": jewishEducator
    });
0

1 Answer 1

4

In your class you are declaring the variable name as jewishEducatorString however, when you are setting parameters in your client side controller you are attempting to pass it as jewishEducator.

so, by changing

"jewishEducator:": jewishEducator

to

"jewishEducatorString:": jewishEducator

should do the trick.

One last thing, ensure that your variables are of the same type when passing from one controller to another.

0

You must log in to answer this question.

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