+ Start a Discussion
Peter McGavinPeter McGavin 

Cannot complete trailhead Hands on challenge (Level up with Advanced formulas - missing opportunities createdDate field).

Hi,
The trailhead challenge for Admin Advanced  Advanced Formulas (Level Up with Advanced Formulas) states:
Create a formula that shows where an Opportunity is in the pipeline.
Create a formula field that classifies an Opportunity as either “Early”, “Middle”, or “Late”. This formula field should use TODAY() to calculate what percentage of the time between an opportunity’s CreatedDate and CloseDate has passed, and label the opportunity accordingly.

My question is where is the createdDate field in the oppotunities object? The challenge implies this is an existing field but I cannot find it. 
Also what is meant by percentage of time passed in this context? Does this mean 'the time passed between the createdDate and closedDate' in relation to (i.e. divided by) 'the time passed between the createdDate and TODAY' ? 

Thanks in advance.
Best Answer chosen by Peter McGavin
jigarshahjigarshah
CreatedDate is one of the standard auditing fields provided by Salesforce on every standard and custom object. You should be able to view the CreatedDate field within the Formula Editor while building the formula field or on the Opportunity Record Page provided it is added to the respective page layout. The CreatedDate field does not show up neither within the Object Manager nor the Schema Builder but is made available fby default.

Percentage of time passed means you will have to find the difference between Today and CreateDate and divide that by the total duration of Opportunity Closure. So your formula to derive the percentage of time elapsed would be as follows.
TODAY() - CreatedDate / CloseDate - CreatedDate
Use this in combination with the formula to display the text on Opportunity as either “Early”, “Middle”, or “Late” based on the percentage bucket associated with each text. (Hint: Use the CASE() function within formula fields to display the respective text based on the Time Elapsed % Bucket Value.)

Please do not forget to mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.

All Answers

jigarshahjigarshah
CreatedDate is one of the standard auditing fields provided by Salesforce on every standard and custom object. You should be able to view the CreatedDate field within the Formula Editor while building the formula field or on the Opportunity Record Page provided it is added to the respective page layout. The CreatedDate field does not show up neither within the Object Manager nor the Schema Builder but is made available fby default.

Percentage of time passed means you will have to find the difference between Today and CreateDate and divide that by the total duration of Opportunity Closure. So your formula to derive the percentage of time elapsed would be as follows.
TODAY() - CreatedDate / CloseDate - CreatedDate
Use this in combination with the formula to display the text on Opportunity as either “Early”, “Middle”, or “Late” based on the percentage bucket associated with each text. (Hint: Use the CASE() function within formula fields to display the respective text based on the Time Elapsed % Bucket Value.)

Please do not forget to mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.
This was selected as the best answer
Peter McGavinPeter McGavin
Thanks for the clarification, however when I tried the above formula I received the follow syntax error message:
Error: Incorrect parameter type for operator '/'. Expected Number, received DateTime
 
jigarshahjigarshah
Peter, the issue is necause mathematical operators do not work with DateTime values. Hence, you will need to convert the difference between the 2 days into number i..e number of days and then use that numeric values to get the percentage values using the division operator.
Peter McGavinPeter McGavin
Hi, as I cannot currently access the Trailhead forum (due to password issues) can you please assist with the following query: In the Visual Force unit (Developer beginner) it says: 'To preview your page in the context of Lightning Experience, open your browser’s developer console and enter' $A.get("e.force:navigateToURL").setParams( {"url": "/apex/pageName"}).fire(); I am not sure what this means. I click on the developer tools in Chrome and click the console button and enter the suggested code but all I get is an error: Uncaught ReferenceError: $A is not defined at :1:1 Please assist. Thanks. Peter McGavin (user pmacfb@cunning-bear-27155.com)
jigarshahjigarshah
Peter,

Can you create a separate thread for this?
Peter McGavinPeter McGavin
I can't get into the forum page - as mentioned I am having access issues.
jigarshahjigarshah
You will need to navigate to Options > Developer Tools or click Ctrl + Shift + J on your keyboard to bring up the Developer tools window in your Chrome browser.

Navigate to the Console tab within as shown below and type in the requested code. This will open up your requested Visualforce page within the Lightning Experience mode of Salesforce.

In the screenshot below I am referring to a custom Visualforce Page that I created with the name JqueryTabSample

VF Page in Salesforce LEX

Hope that helps.
Peter McGavinPeter McGavin
Great. Seems to work when I pysically type the code in (rather than copy-paste).
Thanks again.
Scott Metcalfe 5Scott Metcalfe 5
I passed the Challenge with the following formulas but my Opportunity Progress field doesn't show the correct value.
 
(TODAY() - DATEVALUE(CreatedDate)) / (CloseDate - DATEVALUE(CreatedDate))
 
IF(Percent_Completed__c <= 25, "Early", 
IF(Percent_Completed__c > 25 && Percent_Completed__c < 75, "Middle","Late"))

 
Scott Metcalfe 5Scott Metcalfe 5
I passed the Challenge with the following formulas but my Opportunity Progress field doesn't show the correct value.
 
(TODAY() - DATEVALUE(CreatedDate)) / (CloseDate - DATEVALUE(CreatedDate))
 
IF(Percent_Completed__c <= 25, "Early", 
IF(Percent_Completed__c > 25 && Percent_Completed__c < 75, "Middle","Late"))

 
Jeanne Zhan 1Jeanne Zhan 1
Scott, I think the numbers in your formula should be 0.25 and 0.75.
IF( Percent_Completed__c <= 0.25, "Early",
IF(Percent_Completed__c > 0.25 &&
Percent_Completed__c < 0.75,"Middle",
"Late"))