Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Date field automatcailly changing when tabbing through other scripted fields

_Ken_Adkins_
Level 2
Level 2
I have a form with a datetime field. The object is readonly. I format the field with javascript as yyyymmddhhmmss as a tracking number for the form. When tabbing through other fields with javascript the value changes to the current date time, like the code is being executed each time a scripted field is entered.



Any ideas how to prevent that? I just want the code to execute when the form is opened.



----- form1.sbfDirect_Pay.dteCurrentDate::ready:layout - (JavaScript, client) ----------------------



// Current Date in short-style date format.



// $.rawValue = num2date(date(), DateFmt(1, "))

var varCurrentTime = new Date();

var varYear = varCurrentTime.getFullYear();

var varMonth = varCurrentTime.getMonth() + 1;

var varDay = varCurrentTime.getDate();

var varHour = varCurrentTime.getHours();

var varMin = varCurrentTime.getMinutes();

var varSec = varCurrentTime.getSeconds();



if(varMonth<10) varMonth = "0" + varMonth;

if(varDay<10) varDay = "0" + varDay;

if(varHour<10) varHour = "0" + varHour;

if(varMin<10) varMin = "0" + varMin;

if(varSec<10) varSec = "0" + varSec;



// $.rawValue = year + "" + month + "" + day + "" + hour + "" + min + "" + sec;



dteCurrentDate.rawValue = varYear + "" + varMonth + "" + varDay + "" + varHour + "" + varMin + "" + varSec;
1 Reply
_Ken_Adkins_
Level 2
Level 2
I think I just answered my own question. The code was in the layout:ready event. This area is executed each time the layout is modified. I moved the code to form:ready event.



🙂