first commit Riabu
This commit is contained in:
5
force-app/main/default/triggers/AccountTrigger.trigger
Normal file
5
force-app/main/default/triggers/AccountTrigger.trigger
Normal file
@@ -0,0 +1,5 @@
|
||||
trigger AccountTrigger on Account (after insert, after update) {
|
||||
AccountTriggerHandler.createCustomer(Trigger.New);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<apiVersion>65.0</apiVersion>
|
||||
<status>Active</status>
|
||||
</ApexTrigger>
|
||||
12
force-app/main/default/triggers/ContactTrigger.trigger
Normal file
12
force-app/main/default/triggers/ContactTrigger.trigger
Normal file
@@ -0,0 +1,12 @@
|
||||
trigger ContactTrigger on Contact (after insert, after update) {
|
||||
|
||||
if (Trigger.isAfter) {
|
||||
if (Trigger.isInsert || Trigger.isUpdate) {
|
||||
// Only run trigger logic if allowed
|
||||
if (ContactTriggerHandler.becamePrimary) {
|
||||
System.debug('Trigger executed - becamePrimary is TRUE');
|
||||
// your logic here if needed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<apiVersion>65.0</apiVersion>
|
||||
<status>Active</status>
|
||||
</ApexTrigger>
|
||||
@@ -0,0 +1,29 @@
|
||||
trigger OpportunityAfterTrigger on Opportunity(after update, after insert){
|
||||
map<Id, List<Decimal>> accIdOppAmtMap = new map<Id, List<Decimal>>();
|
||||
List<Account> accListToUpdate = new List<Account>();
|
||||
for(Opportunity opp : Trigger.new){
|
||||
accIdOppAmtMap.put(opp.accountId, new List<Decimal>());
|
||||
|
||||
}
|
||||
if(accIdOppAmtMap.size() > 0){
|
||||
|
||||
List<Opportunity> oppList = [Select AccountId, Amount From Opportunity Where AccountId IN : accIdOppAmtMap.keySet() Order By Amount DESC] ;
|
||||
|
||||
for(Opportunity opp : oppList){
|
||||
if(accIdOppAmtMap.ContainsKey(opp.AccountId)){
|
||||
accIdOppAmtMap.get(opp.AccountId).add(opp.Amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(Id accId : accIdOppAmtMap.KeySet()){
|
||||
Account acc = new Account(Id = accId);
|
||||
if(accIdOppAmtMap.get(accId).size() > 1){
|
||||
acc.AnnualRevenue = accIdOppAmtMap.get(accId).get(1);
|
||||
} else{
|
||||
acc.AnnualRevenue = accIdOppAmtMap.get(accId).get(0);
|
||||
}
|
||||
accListToUpdate.add(acc);
|
||||
}
|
||||
update accListToUpdate;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<apiVersion>63.0</apiVersion>
|
||||
<status>Active</status>
|
||||
</ApexTrigger>
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<apiVersion>61.0</apiVersion>
|
||||
<packageVersions>
|
||||
<majorNumber>3</majorNumber>
|
||||
<minorNumber>71</minorNumber>
|
||||
<namespace>CHANNEL_ORDERS</namespace>
|
||||
</packageVersions>
|
||||
<packageVersions>
|
||||
<majorNumber>1</majorNumber>
|
||||
<minorNumber>21</minorNumber>
|
||||
<namespace>sfLma</namespace>
|
||||
</packageVersions>
|
||||
<status>Active</status>
|
||||
</ApexTrigger>
|
||||
Reference in New Issue
Block a user