Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
var startDateCustomFieldId = 10101;//Date picker - Start Date
var testDaysCustomFieldId = 10200;//Number field - Test Length in Days


calculate()

function calculate(){
  	var now = new Date()
	var start = cfValues[startDateCustomFieldId]
	var testingDays = cfValues[testDaysCustomFieldId]
	
	if(start !== null){  || if(start.getTime() > now.getTime() ){
  	0
   || testingDays == null || testingDays == 0){
		return 0
	} else {
	  	return Math.min(100, Math.round(dayBetweenDates(start, now)/cfValues[testDaysCustomFieldId]testingDays*100))
  	}
}


function dayBetweenDates(date1, date2){
	return (date2.getTime() - date1.getTime())/ (1000 * 3600 * 24)
}

...

Code Block
languagejs
var endDateCustomFieldId = 10011;//Formula date field - End Date
var agingCustomFieldId = 10202;//Number field - Aging Length in Days

calculate()

function calculate(){
  	var now = new Date()
	var end = cfValues[endDateCustomFieldId]
	var agingDays = cfValues[agingCustomFieldId]
	
	if(end !== null){  || if(end.getTime() > now.getTime() ){
  	0
   || agingDays == null || agingDays == 0){
		return 0
	} else {
	  	return Math.min(100, Math.round(dayBetweenDates(end, now)/cfValues[agingCustomFieldId]agingDays*100))
  	}
}


function dayBetweenDates(date1, date2){
	return (date2.getTime() - date1.getTime())/ (1000 * 3600 * 24)
}

...