Copy link to clipboard
Copied
Hi All,
I am trying to automate the fillable field formating based on the field name, is it possible to set the field format based on the field format, I tried below script however it seems nothing changed and not showing any error. However if i am not using the arr and use one field name it works.
Any help much appreciated.
var arr = ['clm_bdate','di_date','ee_end_date_occ','ee_start_date_occ','ft_date','pt_date',' bdate_youngest', 'injury_date'];//date field names
for (var i = 0; i < this.numFields; i++) {
var A = this.getField(this.getNthFieldName(i));
if (arr.indexOf(A) >= 0) {
var cFormat = "mm/dd/yyyy";
A.setAction("Format", "AFDate_FormatEx(\""+cFormat+"\")");
A.setAction("Keystroke", "AFDate_KeystrokeEx(\""+cFormat+"\")");
}
}
this.getField("A").userName="Enter the Date in MM/DD/YYYY Format";
Copy link to clipboard
Copied
Copy link to clipboard
Copied
That's because A is not a field name. It's a variable that points to a Field object.
So it needs to be:
A.userName="Enter the Date in MM/DD/YYYY Format";
Also, you have to move that line up so it's inside the for-loop where A is defined.
Copy link to clipboard
Copied
Use the name of the field:
if (arr.indexOf(A.name) >= 0) {
Copy link to clipboard
Copied
Wow. That worked Bernd, Thank you so much, Also the tooltip (userName) not getting update on the date field.
Copy link to clipboard
Copied
That's because A is not a field name. It's a variable that points to a Field object.
So it needs to be:
A.userName="Enter the Date in MM/DD/YYYY Format";
Also, you have to move that line up so it's inside the for-loop where A is defined.
Copy link to clipboard
Copied
Thank you so much try67 it worked fine.