Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Accessing a Text Field and Date Math

Avatar

Former Community Member
Is this a bug, or is there something I'm missing. I want to change the text in a TextField based on the date. But, the text does not get set after I use the util.scand() method.



I know this sounds weird. I made a blank form with nothing but the TextField on it. And, the code below is all there is.



xfa.form.form1.SubForm.TextField1.rawValue = "Before";

var strExpireDate = "11/07/07";



/* Turn the Expire Date into a Date Object */

var dateExpireDate = new Date();



//Comment out the following line and it works

dateExpireDate = util.scand("mm/dd/yy", strExpireDate);



xfa.form.form1.SubForm.TextField1.rawValue = "After";



With this code, if you Preview the PDF, the TextField stays stuck on "Before." If you comment out the line with the util.scand() method, the TextField will show up as "After".



Any ideas?
1 Reply

Avatar

Former Community Member
util.scand() is used for converting date/time values to a specific format. You don't have any type of decision making scripting in your example code. You are going to want to set up your scripts with an IF statement. Where IF the date is one value or a range of values you set the field to "After", else set it to "Before":



if(dateExpireDate == util.scand("mm/dd/yy", strExpireDate))

{

xfa.form.form1.SubForm.TextField1.rawValue = "After";

}

else

{

xfa.form.form1.SubForm.TextField1.rawValue = "Before";

}



The above statement should set the rawValue of the field to After if dateExpireDate = strExpireDate, and Before if the two date values are different.