Skip to main content
Inspiring
March 13, 2021
Answered

Console Error Not Function, But Similar Script runs ok in another dateobject field

  • March 13, 2021
  • 1 reply
  • 811 views

I have a series of three date object fields for business and for mobilehome: StartDate, EndDate, and AdvancedRenewalPeriodDate. The AdvancedRenewalPeriodDate calculates in days the difference between the EndDate field value minus 90 days. I took my scripts for these (business,mobilehome) AdvancedRenewalPeriodDate fields from the calculation script located in my original AdvancedRenewalPeriodDate used when BirthDate dateobject is involved. For some reason, my new ones (business,mobilehome) do not work. What am I missing???????  File Attached- Thanks in advance!!! 

 

//START DATE Registration Period for BUSINESS NOT FOR HIRE or

//SHORT TERM RENTAL JUN 01
var sACQb = this.getField("AcquiredDate").valueAsString;
if (sACQb == "") event.value = "";
else {
var dsACQb = util.scand("mm/dd/yyyy",sACQb);
dsACQb.setMonth(05);
dsACQb.setDate(01);
event.value = util.printd("mm/dd/yyyy", dsACQb);}

//END DATE Initial Registration Period for BUSINESS NOT FOR HIRE or

//SHORT TERM RENTAL MAY 31
var eACQb = this.getField("AcquiredDate").valueAsString;
if (eACQb == "") event.value = "";
else {
var deACQb = util.scand("mm/dd/yyyy",eACQb);
deACQb.setMonth(05);
deACQb.setDate(30);
event.value = util.printd("mm/dd/yyyy", deACQb);}

//businessADVANCEDRENEWALPERIODDATE BUSINESS NOT FOR HIRE or
//SHORT TERM RENTAL ENDDATE-90days
var bARP = this.getField("businessEndDate").valueAsString;
if (bARP == "") event.value = "";
else {
var dbARP = util.scand("mm/dd/yyyy", bARP);
dbARP.setDate(bARP.getDate()-90);
event.value = util.printd("mm/dd/yyyy", dbARP);}
______________________________________________________________________
//mobilehomeSTARTDATE JAN 1
var sACQmh = this.getField("AcquiredDate").valueAsString;
if (sACQmh == "") event.value = "";
else {
var dsACQmh = util.scand("mm/dd/yyyy",sACQmh);
dsACQmh.setMonth(00);
dsACQmh.setDate(01);
event.value = util.printd("mm/dd/yyyy", dsACQmh);}

//mobilehomeENDDATE DEC 31
var eACQmh = this.getField("AcquiredDate").valueAsString;
if (eACQmh == "") event.value = "";
else {
var deACQmh = util.scand("mm/dd/yyyy",eACQmh);
deACQmh.setMonth(11);
deACQmh.setDate(31);
event.value = util.printd("mm/dd/yyyy", deACQmh);}

//mobilehomeAdvancedRenewalPeriodDate ENDDATE-90days
var mhARP = this.getField("mobilehomeEndDate").valueAsString;
if (mhARP == "") event.value = "";
else {
var dmhARP = util.scand("mm/dd/yyyy", mhARP);
dmhARP.setDate(mhARP.getDate() - 90);
event.value = util.printd("mm/dd/yyyy", dmhARP);}

This topic has been closed for replies.
Correct answer Bernd Alheit

You can't use

bARP.getDate()

bARP is a string. The function getDate() is not available for strings.

dbARP is a date object.

1 reply

try67
Community Expert
Community Expert
March 13, 2021

bARP is a string, not a Date object.

Inspiring
March 14, 2021

I do not follow. I thought the util.scand interpreted the variable into date format chosen?

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
March 14, 2021

You can't use

bARP.getDate()

bARP is a string. The function getDate() is not available for strings.

dbARP is a date object.