You need to sign in to do that
Don't have an account?
Jeremy Gaisie
Calling a Class Method from a Trigger
Note: This is not a 'challenge' related question. I'm either experiencing a bug or have another issue preventing account creation in the Salesforce UI.
The tutorial link can be found here (https://developer.salesforce.com/trailhead/apex_triggers/apex_triggers_intro):
I'm having difficulty following the Trailhead Tutorial titled: 'Getting Started with Apex Triggers', from section: 'Calling a Class Method from a Trigger'. The step I am following is copied from th etutorial here:
1) Add the following trigger using the Developer Console (follow the steps of the HelloWorldTrigger example but useAddRelatedRecord for the trigger name).
2) To test the trigger, create an account in the Salesforce user interface and name it Apples & Oranges.
(this image may be too small to read, the solution is to open it in another tab)
I have copied and pasted the code for all of the relevant classes and triggers in this tutorial and have used the described titles. I am using HaoIDE for my text editor, however I don't believe this is an issue, as copies are saved to the Salesforce Platform.
What 'discount' is being referred to in the error message? I was under the impression that the only required field for an account is the name?
I believe I can continue to create accounts by removing the related trigger but would prefer to find answers to this problem, if possible.
Thanks in advance to any suggestions
The tutorial link can be found here (https://developer.salesforce.com/trailhead/apex_triggers/apex_triggers_intro):
I'm having difficulty following the Trailhead Tutorial titled: 'Getting Started with Apex Triggers', from section: 'Calling a Class Method from a Trigger'. The step I am following is copied from th etutorial here:
1) Add the following trigger using the Developer Console (follow the steps of the HelloWorldTrigger example but useAddRelatedRecord for the trigger name).
2) To test the trigger, create an account in the Salesforce user interface and name it Apples & Oranges.
(this image may be too small to read, the solution is to open it in another tab)
I have copied and pasted the code for all of the relevant classes and triggers in this tutorial and have used the described titles. I am using HaoIDE for my text editor, however I don't believe this is an issue, as copies are saved to the Salesforce Platform.
What 'discount' is being referred to in the error message? I was under the impression that the only required field for an account is the name?
I believe I can continue to create accounts by removing the related trigger but would prefer to find answers to this problem, if possible.
Thanks in advance to any suggestions
oppList.add(new Opportunity(Name=a.Name + ' Opportunity',
StageName='Prospecting',
CloseDate=System.today().addMonths(1),
AccountId=a.Id,
Discount_Percent__c=0)); //Add 0 or your chosen percentage
All Answers
I just tried the trigger and it worked without any errors. Please make sure that you don't have any validation rules or triggers enabled on Account object. You can check them under
Setup -> Accounts -> Triggers
Setup -> Accounts -> Validation Rules
Make them inactive and try again. Thanks!
oppList.add(new Opportunity(Name=a.Name + ' Opportunity',
StageName='Prospecting',
CloseDate=System.today().addMonths(1),
AccountId=a.Id,
Discount_Percent__c=0)); //Add 0 or your chosen percentage