You need to sign in to do that
Don't have an account?
simon chao
before insert trigger help
I am wondering how I can come about this trigger.
I want to write a before insert trigger that fires whenever a new benefit record is created. It will take in value from a look up object, company__c,
and prepopulate its custom fields medical_location__c, date_of_subscription__c and medical_description__c field and stamp it on the benefit form. Any help on how I can go about this?
I want to write a before insert trigger that fires whenever a new benefit record is created. It will take in value from a look up object, company__c,
and prepopulate its custom fields medical_location__c, date_of_subscription__c and medical_description__c field and stamp it on the benefit form. Any help on how I can go about this?
All Answers
trigger TestTrigger on Benifit__c (before insert) {
Set<Id> cmpnyIds = new Set<Id>();
for (Benifit__c : Trigger.new) {
if (c.Lookup__c != null) {
cmpnyIds .add(c.Lookup__c); }
} // Handy special map constructor
Map<Id, company__c> cmpnyRecords = new Map<Id, company__c>([ select Id, medical_location__c,date_of_subscription__c from company__cwhere Id in :cmpnyIds ]);
for (Benifit__c b : Trigger.new) {
if (b .company__c!= null) {
company__ca = cmpnyRecords .get(c.company__c); // Use a with c
}
}
}
Thanks!
I tried this, but trigger still overwrites