DekYingTong
Nintex Observer

Need a returned value as "date" using Calculated Value form control - pls help!

 

I'm trying to yield a date value using calculated value form. Tried and not working, can you pls help 🙂

The form is for employee to add their child birth date (time/date form), and another field should yield the date 6 years after the given date, which I cannot make it happen.

i use calculated value form and put in this formula, and when i tried preview the form, it kept saying 'yesr' is undefined.

example of what i simply want is, i.e. selected BD is 15-MAY-2014, the yield value should be 15-MAY-2020.  Thanks a bunch

 

to select BD

2020-02-07_14-48-39.png

 

 

formula

2020-02-07_14-51-05.png

 

error msg

2020-02-07_14-32-45.png

 

0 Kudos
Reply
1 Reply
Michel
Process Pupil

Re: Need a returned value as "date" using Calculated Value form control - pls help!

Too bad it's not as simple as we hope it would be. However, there is another post on the community that solves this issue. Please check out https://community.nintex.com/t5/Nintex-for-SharePoint/Calculate-Date-based-on-another-date/td-p/3950 and see if that works for you!

 

The answer from Eric Beeler:

I received some help on the JavaScript and got the dates to work. I needed to add validateStoredDate(); after the ready function. The first date is +2 days and the second one is today's date.

 

So my full script reads as followed:

NWF$(document).ready(function()
{
  validateStoredDate();
});

 

function validateStoredDate(source, arguments)
{
  var varStoredDate = NWF$('#' + varStoredDateID);
  var varCalculatedDate = NWF$('#' + varCalculatedDateID);

 

  // get date from first date picker
  var depart = parseDate(varStoredDate.val(),'mm/dd/yy');

 

  // add 129 days to the retrieved date
  depart.setDate(depart.getDate() + 2);

 

  // update second date picker
  varCalculatedDate.datepicker('setDate',depart);

 

  arguments.IsValid = true;
}

 

function parseDate(dateString, userFormat) {
    var delimiter, theFormat, theDate, month, date, year;
    // Set default format if userFormat is not provided
    userFormat = userFormat || 'yyyy-mm-dd';

 

    // Find custom delimiter by excluding
    // month, day and year characters
    delimiter = /[^dmy]/.exec(userFormat)[0];

 

    // Create an array with month, day and year
    // so we know the format order by index
    theFormat = userFormat.split(delimiter);

 

    //Create an array of dateString.
    theDate = dateString.split(delimiter);
    for (var i = 0, len = theDate.length; i < len; i++){
      //assigning values for date, month and year based on theFormat array.
      if (/d/.test(theFormat)){
        date = theDate;
      }
      else if (/m/.test(theFormat)){
        month = parseInt(theDate, 10) - 1;
      }
      else if (/y/.test(theFormat)){
        year = theDate;
      }
    }
    return (new Date(year, month, date));
}

0 Kudos
Reply