first commit Riabu

This commit is contained in:
2025-11-26 15:57:11 +05:30
parent dd002222ad
commit a5dea75cc3
51 changed files with 14671 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
trigger linkCOACustomerToLMALicense on CHANNEL_ORDERS__Customer__c (after insert, after update) {
// map to capture license id + customer id
map<string,id> allCustomersWithOrgID = new map<string,id>();
// retrieve all customer org id in the trigger
string customerOrgId = '';
for (CHANNEL_ORDERS__Customer__c c : trigger.new)
{
customerOrgId=c.CHANNEL_ORDERS__Customer_Org_ID__c;
allCustomersWithOrgID.put(customerOrgId.left(15), c.id);
}
list<sfLma__License__c> licenseToUpdate = new list<sfLma__License__c>();
// retrieve all licenses
list<sfLma__License__c> allLicensesWithCustomer = [select id, sfLma__Account__c, COA_Customer__c, sfLma__Subscriber_Org_ID__c
from sfLma__License__c
where sfLma__Subscriber_Org_ID__c in :allCustomersWithOrgID.keyset()];
for (sfLma__License__c mylicense : allLicensesWithCustomer)
{
// assigne the right customer to the right license via orgid
mylicense.COA_Customer__c = allCustomersWithOrgID.get(mylicense.sfLma__Subscriber_Org_ID__c);
licenseToUpdate.add(mylicense);
}
update licenseToUpdate;
}