function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jayne MonatJayne Monat 

Trailhead: Number formula that calculates the volume of a cylinder

I am working on the Trailhead challenge asking me to create a formula field calculating the volume of a cylinder.  I am 99% sure my formula is correct but the error message I am getting is asking me to include a "required field" that is not mentioned in the challenge.  Here is the prompt:
 
Your company sells cylindrical hyperbaric chambers. You need a formula field that calculates the volume of a cylinder for you, rounded to the nearest whole number, given its radius and height. Use the existing mathematical formula for the volume of a cylinder, V = πr2h, where r is the radius of the cylinder, h is the height, and π is the constant Pi. Note: Although this formula field might best be created on a custom object, for simplicity, we’ll create this formula on the Opportunity object.Create 2 custom fields of type Number on the Opportunity object: ‘radius’ with a resulting API name of ‘radius__c’ and ‘height’ with a resulting API name of ‘height__c’.
The formula should be named ‘Cylinder Volume’, with the resulting API name ‘Cylinder_Volume__c‘ and should be created on the Opportunity object.
The formula should reference the custom fields ‘radius__c‘ and ‘height__c‘.
The formula should use 3.14159 as an approximation of Pi.
 
Here is my formula: 3.14159 *  (radius__c ^2) *  height__c

Here is my error message:
User-added image

Any help would be appreciated!
Best Answer chosen by Jayne Monat
Jeff DouglasJeff Douglas
Jayne,

It looks like you have a required field already on the Opportunity object that is preventing the test from running successfully. Any way you could remove or make that field not required? Or possibly use a brand new developer org as a last resort.

Thanks
Jeff Douglas
Trailhead Developer Advocate

All Answers

Jeff DouglasJeff Douglas
Jayne,

It looks like you have a required field already on the Opportunity object that is preventing the test from running successfully. Any way you could remove or make that field not required? Or possibly use a brand new developer org as a last resort.

Thanks
Jeff Douglas
Trailhead Developer Advocate
This was selected as the best answer
Jayne MonatJayne Monat
Ahh, that makes sense, thanks Jeff!
Olivier WienerOlivier Wiener
You also forgot to round your number, ;-)
Jayne MonatJayne Monat
Oliver, do you mean π?  That part was fine.  The instructions specifically require you to use 3.14159.  The formula worked fine when I disabled (thanks Jeff!) a required field I built in a previous Trailhead training.
Olivier WienerOlivier Wiener
No no, the challenge says "rounded to the nearest whole number". In order to achieve that, the correct formula should be:
round(3.14159 *  (radius__c ^2) *  height__c,0)

;-)
 
Jayne MonatJayne Monat
There is a field in the formula editor where you can select 0 decimal places, which also does the trick, but thanks for the tip.
Olivier WienerOlivier Wiener
I do not fully agree, it will display 3142 as the calculation results in 3141.59, but the actual value is still 3141.59 in SF. The round function will turn that number to 3142.00. My point was that the challenge checking method is probably not verifying if you put that round function in your formula.
Maurizio BertiMaurizio Berti
Thanks to all!   There was a error in the formula (I used the Olivier and Jayne suggestion  radius__c ^2  instead EXP(2) ) but to have the right error message I had to delete IsClosed custom field cretaed in a previous exercise.
Pratyush Kumar 44Pratyush Kumar 44
HI,
Olivier Wiener,
round(3.14159 *  (radius__c ^2) *  height__c,0) its wrong, please correct it, I tried its not working syntax error.
Amit ChattorajAmit Chattoraj
For those who get this error --- >   Answer to the Error Error

I deleted the Discount Percent (Discount_Percent__c) field and it's related Approval process. Used the Formula ----> Cylinder_Volume = Round(3.14159 * height__c * (radius__c^2),0) And it worked fine. Cheers