You need to sign in to do that
Don't have an account?
csathishbabu
Difference between dates in javascript page
Im using a custom button in opportunity tab to get INvoice for a particular Opportunity,In that case the Invoice PAge should Invoke only wen the Opportunity Created date should be less than 21 days from now,so if difference between is greater 21 days it should not invoke Here is my COde in Custom button link display type is detail page button if({!Opportunity.CloseDate} - {!Opportunity.CreatedDate} > 21){ window.parent.location.href = "/apex/Invoice_1?id="+'{!Opportunity.Id}'; }else{ //do nothing } Thanks in Advance Sathish
Hi Satish,
First it is required to calculate number of days in javascript. Following code can aid you in finding difference in days
Hope this example helps
Try out the sample code given below :
if(({!Opportunity.CloseDate} - {!Opportunity.CreatedDate}) > 21)
{
window.parent.location.href = "/apex/Invoice_1?id="+'{!Opportunity.Id}';
}
else
{
//do nothing
}
Hope this helps.