Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

LiveCycle 11 Locking Date Time Box from changing

Avatar

Level 1

Greetings

This is a Check list form that consists of Check Box's, Text Box's and Date and Time Box's

Once the person completes the check they enter there Initials in the TextBox (TXTB1) and on Exit it Automatically checks the TextBox for Data then it Checks the CheckBox (CB1), and enters the Date and time in the DateTime Box (TIMB1) it also makes the CheckBox, TextBox, and DateTime box Read only. I am using JavaScript and FormCalc. I also have it Setting focus to the next CheckBox in the list once you leave the Initials box.

My problem is that if you Tab through the fields again the Time will change. I need to stop the time from changing. Here is the Code I am using.

On Exit. Using Language FormCalc

TIMB1.rawValue = Concat(Num2Date(date(), "M/D/YYYY "), "@ ", Num2Time(time(), "HH:MM:SS"));

TXTB1.access= "readOnly";

TIMB1.access = "readOnly"; 

CB1.access = "readOnly";

xfa.host.setFocus("CB2");

On Change.  Using Language JavaScript

var txtLength = xfa.event.newText.length;

  if(txtLength > 0 ) {

CB1.rawValue = "1";

}

  else {

CB1.rawValue = "0";

}

xfa.event.change = xfa.event.change.toUpperCase();

All code is being used in TXTB1

Thank you for any help you can give me.

Chuck.

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi Chuck,

by 'injecting' I meant this line in your code:

TIMB1.rawValue = Concat(Num2Date(date(), "M/D/YYYY "), "@ ", Num2Time(time(), "HH:MM:SS"));

That's how I assume you put the date and time stamp into the field, right?

So in FormCalc, you could write something like this to make it conditional:

if (TIMB1.rawValue eq null) then

TIMB1.rawValue = Concat(Num2Date(date(), "M/D/YYYY "), "@ ", Num2Time(time(), "HH:MM:SS"));

endif

This code will place the date/time just once, when that field is empty. Once the field is not empty, no more date/time update will happen.

Kindly let me know if any further assistance would be required.

View solution in original post

5 Replies

Avatar

Level 2

Hey Chuck, perhaps you can inject the date time field conditionally, only when that field is empty? That way the date time stamp will be applied just once.

Hope it helps.

Avatar

Level 1

Greetings Sergiy2511

I have commented out the set Focus in the text box's and placed the get date and time code in the click event.  As far as injecting the date and time I am not at that level of programming yet and am not sure on how that would be done.  I am going to try and Attach my pdf so that you can see what I have done.  I hope this makes some kind of sense to you.

OK, I'm so sorry I do not see a way to attach my PDF

Avatar

Correct answer by
Level 2

Hi Chuck,

by 'injecting' I meant this line in your code:

TIMB1.rawValue = Concat(Num2Date(date(), "M/D/YYYY "), "@ ", Num2Time(time(), "HH:MM:SS"));

That's how I assume you put the date and time stamp into the field, right?

So in FormCalc, you could write something like this to make it conditional:

if (TIMB1.rawValue eq null) then

TIMB1.rawValue = Concat(Num2Date(date(), "M/D/YYYY "), "@ ", Num2Time(time(), "HH:MM:SS"));

endif

This code will place the date/time just once, when that field is empty. Once the field is not empty, no more date/time update will happen.

Kindly let me know if any further assistance would be required.

Avatar

Level 7

Hi Chuck,

If you tab through the fields and it changes the date/time. Set the object's access to 'protected'. Protected objects are excluded from tabbing. That might stop it changing since you can't get into it.

Avatar

Level 1

This did the trick, Just moved it to the checkbox so that they had to select the check box, once the check box is checked the Text box, Date and time box and check box is read only. (No tabbing will change the date and time).

Thank you for your help.