You need to sign in to do that
Don't have an account?
Rick Rose
Trigger to update field on a lookup item
On my opportunity I have a lookup to a contact record. When I save an opportunity I want to update a checkbox on the contact record.
here is my code:
trigger flagDonor on Opportunity (after insert) {
for (Opportunity opp : Trigger.new){
//Check and see if there is an individual donor attached to this donation
if(opp.Individual__c!=null){
//update the donor contact to flag as a financial donor
opp.Individual__r.financial_donor__c = TRUE;
}
}
}
but I'm getting this error:
System.NullPointerException: Attempt to de-reference a null object: Trigger.flagDonor: line 8, column 1
here is my code:
trigger flagDonor on Opportunity (after insert) {
for (Opportunity opp : Trigger.new){
//Check and see if there is an individual donor attached to this donation
if(opp.Individual__c!=null){
//update the donor contact to flag as a financial donor
opp.Individual__r.financial_donor__c = TRUE;
}
}
}
but I'm getting this error:
System.NullPointerException: Attempt to de-reference a null object: Trigger.flagDonor: line 8, column 1
Here is some sample code which implements the above suggestion:
If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.
Thanks,
Shashank
All Answers
Hope this will help :)
-N.J
Here is some sample code which implements the above suggestion:
If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.
Thanks,
Shashank