You need to sign in to do that
Don't have an account?
Dr. Thomas Miller
Trailhead: Subscribe to Change Events Using an Apex Trigger
Hi,
my challenge when doing the above mentioned module fails with the following error:
"The test method doesn’t insert an opportunity with the correct fields. Double check the Name, StageName, and CloseDate and try again."
The requirement is as follows:
In the test method, create an opportunity with the following fields.
Name: 'Sell 100 Widgets'
StageName: 'Prospecting'
CloseDate: Date.today().addMonths(3)
And the code is this:
Opportunity opp = new Opportunity(Name='Sell 100 Widgets',
CloseDate=System.Date.today().addMonths(3),
StageName='Prospecting');
insert opp;
Any idea what could be wrong?
my challenge when doing the above mentioned module fails with the following error:
"The test method doesn’t insert an opportunity with the correct fields. Double check the Name, StageName, and CloseDate and try again."
The requirement is as follows:
In the test method, create an opportunity with the following fields.
Name: 'Sell 100 Widgets'
StageName: 'Prospecting'
CloseDate: Date.today().addMonths(3)
And the code is this:
Opportunity opp = new Opportunity(Name='Sell 100 Widgets',
CloseDate=System.Date.today().addMonths(3),
StageName='Prospecting');
insert opp;
Any idea what could be wrong?
You code is totally correct but ... the script of the robot wanted until recently: event.isWon == true
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000IJoxQAG
(... while the documentation clearly says that you must be always "concise" )
It seems that the check by the robot is done for this module on the content of the code directly and not by a real test of an update like before.
Many questions on the forums about this terrible wrong check (that works without == true of course).
All Answers
You code is totally correct but ... the script of the robot wanted until recently: event.isWon == true
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000IJoxQAG
(... while the documentation clearly says that you must be always "concise" )
It seems that the check by the robot is done for this module on the content of the code directly and not by a real test of an update like before.
Many questions on the forums about this terrible wrong check (that works without == true of course).
After you indicated that it might be the robot expecting specific code I tried some stuff and copied from other blog entries.
At the end i found that replacing
System.Date.today().addMonths(3)
by
Date.today().addMonths(3)
did the trick. Unbelievable dumb challenge checking!
There are other restricted method calls to pass the challenge as you mention (unbelievable).
Enough to discourage some people with coding in Apex.
Hi,
I have similar issues,
my test code is:
and my trigger code is:
I don't know where is the trouble. Any idea what could be wrong?