You need to sign in to do that
Don't have an account?
sakthivel
Need Trigger Update
Requirement :
I need to calculate total number of days to close for the each opportunities.
Criteria -
I have a custom field Days to close
Whenever a opportunity record reaches stagename = closed won or lost
- it should update the field Days to close by calculating the total number of days between the record created and stagename = closed won or lost
Sorry if it is confusing, as a newbie i cant explain clearly , still if anybody knows the situation pls help me to create the trigger to update.
Thanks in advance
You can just use a formula field to do this for you....
Formula
Type: Number
Formula: CloseDate - CreatedDate
OR
Formula
Type: Text
Formula: TEXT(CloseDate - CreatedDate) & ' days to close'
but it did not meet my requirement I guess, y because is I need to calculate exactly the record saved date ie stage = lost or won.
close date is just approximate date for opportunity which will be entered during each opportunity creation .
close date and stage fields are not identical , have no relation too if im not wrong .
welcome anymore suggestion .
Well if that's the case when you loop through your results inside your trigger it should work out the same way...
I have created workflow for this ,
criteria
opp.stage = closed won or
opp.stage = closed lost
action
field to update - days to close
formula = today - datevalue(createdDate)
its working fine , whenever I update stage field days to close counts the days ;-)
the pbm is its useful for new records only , but I have 2000 old records if I edit old records it counts till today :-(
thank god I got solution after surfing a lot,
there s standard report type called opp field history , it has some fields like from stage and to stage for tracking purposes , awesome options , reduced lot of pains and saves me time :-)
thanks Alex for help :-)