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
Abhishek RayAbhishek Ray 

Stage Duration

Hi,

 

I need to pull stage duration API name. I can see this field in report. But why can't pull the API from opportunity? Why it is invisible? Please any solutions?

 

Thanks

Abhi

Best Answer chosen by Admin (Salesforce Developers) 
Jia HuJia Hu

I got it.

 

The Stage Duration of an opportunity is the number of days it was in the stage listed in the Stage column. The Stage Duration is a field that only exists on standard reports, not on custom report types. 

 

Based on my understanding, you can't use API to access Stage Duration, but you can get the same value with two custom fields.

 

One is for saving Last Stage Change Date, in fact, 'Last Stage Change Date' exists only in the Custom Report Type for Opportunities but not in the standard report type or on the Opportunity object. Also, can't access with API.

 

1) custom field for saving  Last Stage Change Date

1.Create a date field on the Opportunity Object.

2. Create a workflow rule on the Opportunity.

Enter the Rule Name

Evaluate Rule = Every time a record is created or edited

Rule Criteria

Run this rule if the following = formula evaluates to true

Populate the box with this formula

ISCHANGED(StageName)

Add Workflow Action: New Field Update

Field to update  (Select the date field you created in Step 1)

Check "Use a formula to set the new value"

Enter the formula Today()

 

2) make another custom field to calculate the days between Today() and  Last Stage Change Date

 

 

 

All Answers

Jia HuJia Hu
1. The API name of Stage is StageName
2. what is the message when you query with API
3. check current user's field-level security of the field
Abhishek RayAbhishek Ray

No you are getting it wrong. I am not talking about StageName. If you open your report, there is field called Stage duration. This calculates the no. of days a oppty is sitting on particular stage like if is sitting on prosper stage for 5 days before moving it to progress stage and then sits on that for 12 days. So, the stage duration in total is 17 days. I need to get this field API which will be used by other system. I was thinking to create a formula field which will have an API but since this depends on history tracker how I can generate a formula in it? Thats my question now. Any other suggestion.

 

 

Thanks

Abhishek

Jia HuJia Hu

I got it.

 

The Stage Duration of an opportunity is the number of days it was in the stage listed in the Stage column. The Stage Duration is a field that only exists on standard reports, not on custom report types. 

 

Based on my understanding, you can't use API to access Stage Duration, but you can get the same value with two custom fields.

 

One is for saving Last Stage Change Date, in fact, 'Last Stage Change Date' exists only in the Custom Report Type for Opportunities but not in the standard report type or on the Opportunity object. Also, can't access with API.

 

1) custom field for saving  Last Stage Change Date

1.Create a date field on the Opportunity Object.

2. Create a workflow rule on the Opportunity.

Enter the Rule Name

Evaluate Rule = Every time a record is created or edited

Rule Criteria

Run this rule if the following = formula evaluates to true

Populate the box with this formula

ISCHANGED(StageName)

Add Workflow Action: New Field Update

Field to update  (Select the date field you created in Step 1)

Check "Use a formula to set the new value"

Enter the formula Today()

 

2) make another custom field to calculate the days between Today() and  Last Stage Change Date

 

 

 

This was selected as the best answer
Sivakumari2iSivakumari2i

hey can you give an idea to achieve the secod step you have mentioned?

 

 

 

Tyler KingTyler King
FYI - Adding to Jia's answer... You'll want the formula to be:

OR (ISCHANGED(StageName),ISNEW())

Otherwise, your Last Stage Change field will only update when the stage changes - which leaves you with nothing on new opportunites where the stage has never changed. 

 
Yuhanna SherriffYuhanna Sherriff
Thanks all. perfec answer and example... which all were like this.