Need Help Deciphering the console error messages

Explorer ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

 

I attached the file. The Advanced_Renewal_Period_Date Field and Registration_Time_Period field have custom calculation scripts. The script below is in the Registration_Time_Period field and the source of error is below in red colored text. Basically, the user enters BirthDate and Acquired_Date (mm/dd/yy). The  Advanced_Renewal_Period_Date field value is calculated from the BirthDate value. The Registration_Time_Period field value performs an initial script to change the BirthDate value (oDOB) to the current year (cDOB) . A series variables are set and if statements perform arguments to return a number value representing months. Any help swinging this is greatly appreciated!- thanks in advance- kemper

 

 

var dACQ = this.getField("Acquired_Date").value;
var ARPD = this.getField("Advanced_Renewal_Period_Date").value;

var oDOB = this.getField("BirthDate").valueAsString;
var cDOB = util.scand("mm/dd/yy", oDOB.slice(0,6));
var dACQ = util.scand("mm/dd/yy", dACQ);
var ARPD = util.scand("mm/dd/yy", ARPD);

var msRPSY = cDOB.getTime() - dACQ.getTime();
var ONEDAY = (24 * 60 * 60 * 1000);
var dRPSY = msRPSY/ONEDAY;
dRPSY = Math.floor(dRPSY);
var ONEMONTH = (31 * 24 * 60 * 60 * 1000);
var moRPSY = msRPSY/ONEMONTH;
var ONEYEAR = (12 * 31 * 24 * 60 * 60 * 1000);
var yRPSY = msRPSY/ONEYEAR;

var msRPNY = dACQ.getTime() - cDOB.getTime();
var dRPNY = msRPNY/ONEDAY;
dRPNY = Math.floor(dRPNY);
var moRPNY = msRPSY/ONEMONTH;
var yRPNY = msRPNY/ONEYEAR;

var msARPD = ARPD.getTime();
var msDOB = cDOB.getTime();
var msRGRNP = msDOB + msARPD;

var cbBiennial = this.getField("Biennial").value;
var YREGP = cDOB.setFullYear(cDOB.getFullYear() + 1);
var YYREGP = cDOB.setFullYear(cDOB.getFullYear() + 2);

var msYREGP = YREGP.getTime();

// here's where It has error message unable to find source for Field:Calculate//
var msXRGP = msYREGP + msRGRNP;
var moXRGP = msXRGP / ONEMONTH;


var msYYREGP = YYREGP.getTime();
var msXXRGP = msYYREGP + msRGRNP;
var moXXRGP = msXXRGP / ONEMONTH;

if(oDOB == "") {event.value = "";}
else if (cDOB > dACQ) {event.value = moRPSY;}
else if (cDOB < dACQ) {event.value = moRPNY;}
else if ((dARWP < dACQ < cDOB) && (cbBiennial === "Off")) {event.value = moXRGP;}
else if ((dARWP < dACQ < cDOB) && (cbBiennial !== "Off")) {event.value = moXXRGP;}

TOPICS
How to, JavaScript

Views

85

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Most Valuable Participant , Mar 02, 2021 Mar 02, 2021
I find this website quite useful for that: https://www.w3schools.com/JSREF/jsref_setfullyear.asp Not sure about "layman's terms", as this is quite a technical subject, but it's pretty clear and concise, for the most part.

Likes

Translate

Translate
Explorer ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

made some corrections but still having that same problem shown in red text- attaching updated version with corrections

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

Replace:

 

 var YYREGP = cDOB.setFullYear(cDOB.getFullYear() + 1);

 

with:

 

 var YREGP = cDOB;
 YREGP.setFullYear(cDOB.getFullYear() + 1);

 

The function getTime is only available for date objects.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 01, 2021 Mar 01, 2021

Copy link to clipboard

Copied

Bernd; thank you (!), that worked. However, my resultant value I have know idea where it's coming from. Can you look at the two text scripts files-  the 2nd txt.file has the line code comments included. I thought using a conversion factor could produce a value that could be used directly in a calculation, which is how the script reads, to obtain a number in months. Does the Date Object have to undergo another conversion to obtain the resultant month value in the Else If statements? Thanks in advance for your response- kemper

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Mar 01, 2021 Mar 01, 2021

Copy link to clipboard

Copied

You need to carefully read the documentation of the methods you're using to find out what values they return (if at all) and what kind of effect they have. For example, setFullYear returns a number, not a Date object, and it modifies the object which calls it, so you don't need to use the return value at all, just access the same object after calling it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 01, 2021 Mar 01, 2021

Copy link to clipboard

Copied

try67 you are absolutely correct- just haven't found a source that explains it in layman's terms. That's why you and the others taking valuable time out of your calendar to educate us is so overwhelmingly appreciated.  Thank you all!!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Mar 02, 2021 Mar 02, 2021

Copy link to clipboard

Copied

I find this website quite useful for that:

https://www.w3schools.com/JSREF/jsref_setfullyear.asp

Not sure about "layman's terms", as this is quite a technical subject, but it's pretty clear and concise, for the most part.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 02, 2021 Mar 02, 2021

Copy link to clipboard

Copied

more stuff like Thom's 3-part series on Date objects. Thom starts at the beginning and explains not only the function of the characters used but their purpose, using examples that demonstrate why the code is written in a particular way for a particular event. Many times here in the community I experience difficulty in interpreting the snippets of code, asking myself "why did they do that here when they did that there!!??". But I'm also grateful for your's and others' guidance that encourages us, well at least me, to learn and experiment, and most, enjoy- thank you!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 06, 2021 Mar 06, 2021

Copy link to clipboard

Copied

LATEST

Thanks for the fishing pole! Great site and able to use to decipher adobe's developer reference guide!! 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 02, 2021 Mar 02, 2021

Copy link to clipboard

Copied

Following will not work:

 (dARWP < dACQ < cDOB)

 

Use this:

  (dARWP < dACQ && dACQ < cDOB)

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines