Configure conversion mapping header
This configuration is applicable only for the customers who are using both Q2 Origination and Q2 Loan servicing.
To configure the conversion mapping header, follow the steps:
Log in to your Salesforce account.
Go to the App Launcher, search for Q2 Origination, and select it.
Navigate to Origination Configuration > Company and Application Setup > Conversion Setup > Conversion Mapping Header.
Select the Conversion Mapping Header as required.
Go to the Related tab of the Conversion Header.
Select New for the Conversion Mapping, and provide the following details of the mappings, and Save the conversion mapping.
Product Type Source Field Name Source Field Object Target Field Name Target Object Name Type of Child Relation Loan clcommon__Points__c genesis__Applications__c clcommon__Points__c loan__Loan_Account__c Other
The Product Types in the above table must be updated based on the product for which the conversion mapping header is being configured.
Whenever you convert an application to a CL Contract, once the CL contract is successfully created, the following script must be executed to create the record of the CL Contract Party and associate those with the Points records:
void conversionMappingForBrokerParty(Id appId, Id contractId){
if(String.isEmpty(appId) || String.isEmpty(contractId)){
System.debug(LoggingLevel.ERROR, 'In BrokerPartyConversion.conversionMappingForBrokerParty(), appId or contractId value is passed as null.');
return;
}
List<clcommon__Party__c> parties = [SELECT Id,
clcommon__Account__c,
clcommon__Account__r.clcommon__broker__c,
clcommon__Commission_Plan__c,
clcommon__Contact__c,
clcommon__Party_Types__c,
genesis__Application__c
FROM clcommon__Party__c
WHERE (genesis__Application__c =: appId
AND clcommon__Account__r.clcommon__broker__c = true)
WITH SECURITY_ENFORCED];
if(parties.size() <= 0){
return;
}
//insert Contract parties
List<loan__Coborrower__c> cParties = new List<loan__Coborrower__c>();
for(clcommon__Party__c brokerparty: parties){
loan__Coborrower__c cParty = new loan__Coborrower__c();
cParty.loan__Account__c = brokerParty.clcommon__Account__c;
cParty.loan__Program__c = brokerParty.clcommon__Commission_Plan__c;
cParty.loan__Contact__c = brokerParty.clcommon__Contact__c;
cParty.loan__Party_Type__c = 'BROKER';
cParty.loan__Loan__c = contractId;
cParties.add(cParty);
}
insert cParties;
//fetch points for contractId
List<clcommon__Points__c> points = [SELECT Id,
clcommon__Party__c,
clcommon__Party__r.clcommon__Account__c,
loan__Loan_Account__c,
loan__Coborrower__c
FROM clcommon__Points__c
WHERE (loan__Loan_Account__c =: contractId
AND clcommon__Party__c IN :parties)
WITH SECURITY_ENFORCED];
if(points.isEmpty()){
return;
}
//create accountId to points map
Map<Id, List<clcommon__Points__c>> accountIdPointsMap = new Map<Id, List<clcommon__Points__c>>();
for(clcommon__Points__c point: points){
Id accountId = point.clcommon__Party__r.clcommon__Account__c;
if(!accountIdPointsMap.containsKey(accountId)){
accountIdPointsMap.put(accountId,new List<clcommon__Points__c>{point});
} else{
List<clcommon__Points__c> pointsList = accountIdPointsMap.get(accountId);
pointsList.add(point);
}
}
//fetch contract party records for contractID
List<loan__Coborrower__c> contractParties = [SELECT Id,
loan__Account__c,
loan__Loan__c
FROM loan__Coborrower__c
WHERE loan__Loan__c =: contractId
AND loan__Account__r.clcommon__Broker__c = true
WITH SECURITY_ENFORCED];
//create accountIds to contractParty map
Map<Id, loan__Coborrower__c> accountIdContractPartyMap = new Map<Id,loan__Coborrower__c>();
for(loan__Coborrower__c party: contractParties){
accountIdContractPartyMap.put(party.loan__Account__c, party);
}
List<clcommon__Points__c> recordsToUpdate = new List<clcommon__Points__c>();
for(Id accId: accountIdPointsMap.keyset()){
if(accountIdContractPartyMap.get(accId) != null){
List<clcommon__Points__c> pointsList = accountIdPointsMap.get(accId);
for(clcommon__Points__c point: pointsList){
point.loan__Coborrower__c = accountIdContractPartyMap.get(accId).Id;
recordsToUpdate.add(point);
}
}
}
if(recordsToUpdate.size() > 0){
mfiflexUtil.SecureDML.updateRecords(recordsToUpdate);
}
}
To execute the script, appId and contractId must be passed as an argument.
You can also implement trigger or flow if you wish to run the script automatically on a newly created CL contract.
Id appId = 'a98Hr0000019571IAA';
Id contractId = 'aEBHr0000004GU3OAM';
conversionMappingForBrokerParty(appId, contractId);