You need to sign in to do that
Don't have an account?
pvande
Error: Compile Error: Variable does not exist
I am new to APEX coding and am struggling with the following error. Any help would be apprecaited.
Error: Compile Error: Variable does not exist: Designated_Forecast_Account__c at line 5 column 1
My trigger:
trigger ForecastAccount on Opportunity (before insert, before update) {
if ( Project__r.Sponsor_Account__r.Forecast_Account__c = True) {
Designated_Forecast_Account__c = Sponsor_Account__r.Id ;
} else if
( Project__r.Sponsor_Account__r.Forecast_Account__c = False){
Designated_Forecast_Account__c = Sponsor_Account__r.Reporting_Parent__c ;
}
}
Error: Compile Error: Variable does not exist: Designated_Forecast_Account__c at line 5 column 1
My trigger:
trigger ForecastAccount on Opportunity (before insert, before update) {
if ( Project__r.Sponsor_Account__r.Forecast_Account__c = True) {
Designated_Forecast_Account__c = Sponsor_Account__r.Id ;
} else if
( Project__r.Sponsor_Account__r.Forecast_Account__c = False){
Designated_Forecast_Account__c = Sponsor_Account__r.Reporting_Parent__c ;
}
}
1) First make a formula field on Project__c object named "Forcast Account Checkbox" and it will simpley be checked when Forcast_Account__c is checked.
2) Now we are going to make a use of that field in trigger: Hope this helps!
All Answers
the very first thing I can point out is that you need to use both of those IF statements under the Trigger.New keyword since that way trigger would run for all the opportunity records.
This is should be a starting point in my opinion: Hope this helps!
Account > Project __c > Opportunity
The trigger is on the opportunity. We are trying to access account information on the custom object of Project. Project is related to account via a custom field called Sponsor_Account__c. We are trying to retrieve the boolean field Forecast_Account__c on the Account; if true then we will insert the account ID into the custom field Designated_Forecast_Account__c that resides on the opportunity.
1) First make a formula field on Project__c object named "Forcast Account Checkbox" and it will simpley be checked when Forcast_Account__c is checked.
2) Now we are going to make a use of that field in trigger: Hope this helps!