locked
CRM Date/Time Constant RRS feed

  • Question

  • Hey all,

    Kind of a funny question.  Have a field in CRM 2016 that needs to always be 90 days after Dec 31 of the previous year.

    Hoping to find a nice supported way of doing this.  So before i go and make some complex nonsense to make this work, i though i would reach out and see what other options there may be.

    Thanks

    Thursday, October 27, 2016 5:04 PM

Answers

  • Hello,

    I thought that it's possible to use calculated fields for your requirement but I don't see easy way of describing of formula.

    Actually there are only 2 target date available:

    March 31 for usual year and March 30 for leap year

    So you can use is following onload script:

    var currentYear = (new Date()).getFullYear();
    
    var resultDate = new Date(currentYear, 2, 31);
    
    if (currentYear % 4 === 0){
    
    resultDate.setDate(30);
    
    }
    
    
    
    Xrm.Page.getAttribute("constant field name").setValue(resultDate);



    Dynamics CRM MVP
    Read My blog
    Subscribe for one of my courses

    Thursday, October 27, 2016 6:01 PM
    Moderator

All replies

  • Hello,

    I thought that it's possible to use calculated fields for your requirement but I don't see easy way of describing of formula.

    Actually there are only 2 target date available:

    March 31 for usual year and March 30 for leap year

    So you can use is following onload script:

    var currentYear = (new Date()).getFullYear();
    
    var resultDate = new Date(currentYear, 2, 31);
    
    if (currentYear % 4 === 0){
    
    resultDate.setDate(30);
    
    }
    
    
    
    Xrm.Page.getAttribute("constant field name").setValue(resultDate);



    Dynamics CRM MVP
    Read My blog
    Subscribe for one of my courses

    Thursday, October 27, 2016 6:01 PM
    Moderator
  • Thanks mate
    Saturday, October 29, 2016 4:14 PM