+ Start a Discussion
Aaditya SinghAaditya Singh 

How to create a trigger to calculate the number of days a field was in stop status

Create a new object Survey Request with below fields,
  1. Status – Pick list(Options: Open, Close , Start, Stop)
  2. Stop Started date – date
  3. Total Stop Duration in days-- Integer
  • Create a trigger on survey request to capture the total days for which the survey request was stopped and store the same in Total Stop Duration in day’s field.
Khan AnasKhan Anas (Salesforce Developers) 
Hi Aaditya,

Greetings to you!

You don't need a trigger for that, you can do it through workflow rules.

To calculate the duration of how long a field stays in a particular Picklist Value, please refer to the below knowledge article.


Also, please refer to below links which might help you further.



I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Aaditya SinghAaditya Singh
Hi Anas,

I really appriciate your help regarding above issue but i have got an assignment in which i need to create a trigger for the same.
I have already gone through this article and this is very helpful but currently I am looking for Trigger solution.
Raju yadavRaju yadav
Hi Aaditya,
You can enable field History traking on status field.
It might help you.
Aditya, you may need a schedule job to run everyday at certain time to update records.