Test if the field is null before assigning the current date.
// form1.page1.currentDate::ready:layout - (FormCalc, client)
if (this.isNull) then
$.rawValue = Concat(Num2Date(Date(), "MM/DD/YYYY"))
Here is an example .....you will need to write code on the exit event of the TextField that you want to lock. The corresponding Log Time field wil get set only if you enter a value.
Hope that helps
Time_Log.pdf 77.0 K
Paul, your file has exactly what I want!
But I'd sure love to know how to do that. I'll need to add more of those fields etc so knowing the underpinnings is a necessity.
I was right- the action I wanted was based on 'Calculated-Read Only' in the value setting. However, how to add the script?
Being the newbie that I am, I can't make sense of your answer. I assume you mean to use FormCalc to create the script that the 'Calculated-Read Only' value setting will refer to?
Are you creating your form in Acrobat or LiveCycle Designer. A little hare to tell with all of your posts.
For Acrobat forms:
You can get a lot of different information from the date object by changing the format string for the 'util.printd' method. See the reference George Johnson links to for the format string values that can change the displayed value.
// get new Date object
var d = new Date();
// format to h:MM tt
var sDate = util.printd("h:MM tt", d);
// insert date into form field
this.getField("todaysDate").value = sDate;
h - hours without leading zero
MM - minutes with leading zero if necessary
tt - am or pm designator
For LiveCycle Designer you can select the 'Custom' form tab and then the 'Current Date' field. Now change the script to:
= num2Time(time(), TimeFmt(1))
More information about the time format is the 'Scripting Reference' under LiveCycle Designer's 'Help' menu option.
For the field object, you can set the "Value" "Type:" option to "Calculated - Read Only". But if you use the predefined 'Current Date' field, this is already done for you.
- Open my form in Designer.
- Highlight one of the fields that gets locked.
- In the script editor (above the form design but below the menu items) in the top left is a dropdown labelled Show. This is a dropdown that shows all of the events that this object supports. Anything that has code will have an asterix beside it. In our case th eexit event will have code.Choose the exit event and code will appear in the script window.
- Highlight all of the code including the if and endif statements (do not pick the 1st line that has form1.#subform .......). Copy this code to the clipboard
- I assume that you are doing something similar where you have a field and the Log Time beside it.
- Make sure each field and corresponding time set log field has a unique name.
- Now kighlight the 1st field you want to lock down.
- In the script editor choose the exit event (like we did before)
- Place the cursor after the 1st line in teh script editor and paste the code that is in the clipboard into the script editor.
- NOw we need to modify the script to point to your object names. I have pasted a version of the code below .....teh part in red is the name of my object ...you need to modify it to point to your object names. Thats it.
if ($.rawValue <> null)then
= Num2Time(Time(), "HH:MM:SS")
Strange, the text you mentioned is not showing up in red. I checked in another broswer and it's not showing up either. What was the name of your object?
1 person found this helpful
It looks like the colour is not coming through ....
The object is called Log1 and is at the beginning of the 2nd line.
Got it working!!
Thank you so much, Paul.
Also thanks to those of you who took the time to reply. Really appreciate it.