I'm sure I'm missing something, Please let me know, below is my Helperfunction that I'm calling from controller.JS
insertMailing : function(cmp, event, helper){
var MailingforContact = cmp.get("v.MailingforContact");
MailingforContact.Contact__c = cmp.get("v.recordId");
MailingforContact.Available_Mailing__c = cmp.get("v.selectedRow");
var toastEvent = $A.get('e.force:showToast');
var createAction = cmp.get("c.createMailingRec");
createAction.setParams({
mailingRec: MailingforContact
});
createAction.setCallback(this, function(response){
var state = response.getState();
if(state === 'Success'){
var dataMap = response.getReturnValue();
if(dataMap.status == 'Success'){
toastEvent.setParams({
'title': 'Success!',
'type': 'Success',
'mode': 'dismissable',
'message': dataMap.message
});
toastEvent.fire();
}else if(dataMap.status == 'Error'){
toastEvent.setParams({
'title': 'Error',
'type': 'error',
'mode': 'dismissable',
'message': dataMap.message
});
toastEvent.fire();
}
} else {
alert('Error in getting data');
}
});
$A.enqueueAction(createAction);
$A.get("e.force:closeQuickAction").fire();
}
@ApexController
@AuraEnabled
public static Map<String, String> createMailingRec(Mailings__c mailingRec){
Map<String, String> resultMap = new Map<String, String>();
try{
insert mailingRec;
resultMap.put('status', 'Success');
resultMap.put('message', 'Mailing Inserted Successfully');
}
catch (Exception e){
resultMap.put('status', 'Error');
resultMap.put('message', e.getMessage());
}
return resultMap;
}
Anyhelp is appreciated :)
1 件の回答
Use selectedRows attribute to get the key field ids of selected rows form lightning datatable.
—
Magulan Duraipandian
www.infallibletechie.com