Could someone explain what is happening within these lines in detail, as I am getting an error pointed to these lines. Also please advise on any fixes possible. thanks
approvePaymentRequest: function(component) {
this.submitAction(component, "c.approvePaymentRequest");
},
submitAction: function(component, methodName) {
component.set("v.disabled", true);
this.enqueueAction(component, methodName, { paymentRequestId: component.get("v.paymentRequest.Id") },
function() {
var refreshComponentEvent = $A.get("e.c:refreshComponentEvent");
refreshComponentEvent.setParams({ "event": "paymentRequestUpdated" });
refreshComponentEvent.fire();
component.find("recordLoader").reloadRecord(true);
$A.get("e.force:refreshView").fire();
},
function() {
component.set("v.disabled", false);
}
);
},
APEX
@AuraEnabled
public static void approvePaymentRequest(Id paymentRequestId) {
Payment_Request__c paymentRequest = [SELECT Id, Status__c, Coop_Campaign__c FROM Payment_Request__c WHERE Id = :paymentRequestId];
paymentRequest.Approved_Date__c = Date.today();
paymentRequest.Status__c = 'Approved';
update paymentRequest;
List<Coop_Campaign__c> coopCampaigns = [SELECT Id, Payment_Status__c FROM Coop_Campaign__c WHERE Id = :paymentRequest.Coop_Campaign__c AND (Payment_Status__c = 'Pending Finance Approval')];
if (coopCampaigns.size() > 0) {
Coop_Campaign__c coopCampaign = coopCampaigns[0];
List<Payment_Request__c> paymentRequests = [SELECT Id FROM Payment_Request__c WHERE Coop_Campaign__c = :coopCampaign.Id AND (Status__c = 'Pending Finance Approval')];
if (paymentRequests.size() == 0 && coopCampaign != null) {
coopCampaign.Payment_Status__c = 'Approved';
update coopCampaign;
}
}
}
.cmp
file do you have any component which hasaura:id='recordLoader'
. Your code is trying to look for that component in linecomponent.find("recordLoader").reloadRecord(true);
and is not able to find it?