Trigger Handler:
public with sharing class CallReportTriggerHandler {
public static String loanApp;
@AuraEnabled(cacheable=true)
public static void setFields(object[] aTrigger) {
List<Loan_Application__c> loanAppsToUpdate = new List<Loan_Application__c>();
Set<String> loanAppsIdSet = new Set<String>();
List<Call_Report__c> newTrigger = (List<Call_Report__c>) aTrigger;
for (Call_Report__c callReport : newTrigger) {
if (String.isNotBlank(loanApp)) {
for (String applicationId : loanApp.split(',')) {
if (!loanAppsIdSet.contains(applicationId)) {
Loan_Application__c appObj = new Loan_Application__c();
appObj.Call_Report__c = callReport.Id;
appObj.Id = applicationId;
loanAppsToUpdate.add(appObj);
loanAppsIdSet.add(applicationId);
}
}
}
}
update loanAppsToUpdate;
}
}