Wednesday 10 October 2012

Happy Birth Day Remainders

Below links will give information about the birthday remainders:

http://social.microsoft.com/Forums/en/crmdevelopment/thread/356358fd-071c-40f6-8f35-a90e08ccdcdf

http://blogs.msdn.com/b/crm/archive/2008/01/08/part-1-happy-birthday-via-workflow-using-client-side-scripting.aspx

http://blogs.msdn.com/b/crm/archive/2008/01/11/part-2-happy-birthday-via-workflow-using-custom-workflow-activity.aspx

http://www.dynamicscrmtrickbag.com/2012/06/19/dynamics-crm-and-the-trouble-with-time-zones/

http://blogs.msdn.com/b/crm/archive/2009/02/27/creating-a-birthday-contact-list.aspx

http://blogs.msdn.com/b/crm/archive/2008/01/08/part-1-happy-birthday-via-workflow-using-client-side-scripting.aspx

Age calculations:
http://www.crmconsult.info/2012/02/calculate-age-from-date-of-birth-in.html

calculations:

http://social.microsoft.com/Forums/is/crm/thread/ed37eca2-1d0e-43c5-87d9-d220d624c344

By using java script:


function nextbirthday()
{
   
 var now = new Date();
     var birthday1 = Xrm.Page.getAttribute("new_startdate").getValue();
var result=null;
    var years = now.getYear() - birthday1.getYear();
var aditionalyear= years+1
    var months= now.getMonth() - birthday1.getMonth();

     if(months==0)

{

var days= now.getDay()-birthday1.getDay();

if(days>=1)
{
 result= new Date(birthday1);
result.setYear(result.getYear()+aditionalyear);
Xrm.Page.getAttribute("new_enddate").setValue(result);
}
else
{
result= new Date(birthday1);
result.setYear(result.getYear()+years);
Xrm.Page.getAttribute("new_enddate").setValue(result);
}


}
else
{
if(months>=1)
{

result= new Date(birthday1);
result.setYear(result.getYear()+aditionalyear);
Xrm.Page.getAttribute("new_enddate").setValue(result);

}

else
{

result= new Date(birthday1);
result.setYear(result.getYear()+years);
Xrm.Page.getAttribute("new_enddate").setValue(result);

}
}
}

No comments:

Post a Comment