count cumulative days with UI only field?

  • 1
  • Question
  • Updated 2 years ago
  • Answered
There's a formula field in my SFDC instance that counts total days an Opp is in a certain implementation stage but only calculates after the Opp is moved out of that certain stage.  I'm not allowed to change that field formula since it's tied to too many reports and have been asked to not create a new field in SFDC and keep it in Skuid, if possible. 

I know the UI-only formula to count current days the Opp is in this stage but the problem is an Opp can be moved in and out of this stage more than once and I need to show cumulative days.  Is this possible in Skuid?  Thanks in advance.
Photo of Elise


  • 100 Points 100 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Bill McCullough

Bill McCullough, Champion

  • 13,822 Points 10k badge 2x thumb

I think that one way you can accomplish this with Skuid is to enable field history on the StageName field.  Then you can query the field history records where the StageName changes.  You would then need to write a snippet that will loop through the records and accumulate the number of days that the Opportunity was at a certain stage.  You could display this value directly in a template field instead of a UI field.  Since you want a cumulative total, you have to process the history records using a snippet.  I don't know of any way to use declarative Skuid to get an accumulation of the time at a specific Stage when it will change into and out of that stage.

If your requirement is simply to count the days between the first change to a specific stage and the last change from that stage, then you can use 2 models to get the min/max date of the specific change and subtract the dates to get your days between changes.  This would be a declarative solution.

I think the best option is to create a trigger on Opportunity and have it query the history records to accumulate this total and update a field on the Opportunity.