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
});