This article covers the case where you want to take data from an HG Firmographic field, and populate your own custom field on the Account object.
For this to work, you'll create a trigger for each field you want to populate.
In the sample code below, we take data from HG_Insights__RevenueRange__c and populate it in a custom field called RevenueRange__c
trigger HGFirmographicTrigger on HG_Insights__HGFirmographic__c (after insert, before delete) {
Account acc;
List<Account> accList = new List<Account>();
if (trigger.isAfter && trigger.isInsert) {
for (HG_Insights__HGFirmographic__c hgTech : trigger.new) {
acc = new Account(Id = hgTech.HG_Insights__Account__c);
acc.RevenueRange__c = hgTech.HG_Insights__RevenueRange__c;
accList.add(acc);
}
if (accList.size() > 0) {
update accList;
}
}
if (trigger.isBefore && trigger.isDelete) {
Account acc;
List<Account> accList = new List<Account>();
for (HG_Insights__HGFirmographic__c hgTech : trigger.old) {
acc = new Account(Id = hgTech.HG_Insights__Account__c);
acc.RevenueRange__c = '';
accList.add(acc);
}
if (accList.size() > 0) {
update accList;
}
}
}
Comments
0 comments
Please sign in to leave a comment.