Reputation: 127
I have a form for the Lotus Notes client, that has two fields: outageDate is a Date/Time field, and dayOfWeek, which is a computed field that displays the day of the week depending on the value of outageDate. I can have the second field get updated after EXITING the first field, but what I'd like to do is see the second field get updated AS the value of the first field changes. For example, if I select 12/18/2015 as the outageDate, dayOfWeek displays the word "Friday".
If I arrow up and change the field to 12/17/2015, the day of the week isn't automatically changed to "Thursday". It only changes when the field is exited. I've tried using the Javascript onChange event, but that didn't seem to work.
Upvotes: 2
Views: 1613
Reputation: 127
After tinkering with this for a bit, I found that the Date/Time field can be set to display the three character day of the week, along with the month and day: Ddd MM/DD. This is acceptable. It would be nice to know if there's a way to refresh the form as the field changes value.
After doing more research, I found this IBM Technote:
that documents a property which tells the client to trigger the OnChange (and Exiting) events when the field gets changed. This solves my problem, and the technique can be applied to refreshing the entire form.
What I was really after was the ability to force update of a second field when a preceding field is changed.
Here's a graphic showing the property that can be enabled:
In the form, the field in question now has the following code added to the OnChange/Lotusscript event:
Sub Onchange(Source As Field)
Dim dayOfTheWeek(6) As String
dayOfTheWeek(0) = "Sunday"
dayOfTheWeek(1) = "Monday"
dayOfTheWeek(2) = "Tuesday"
dayOfTheWeek(3) = "Wednesday"
dayOfTheWeek(4) = "Thursday"
dayOfTheWeek(5) = "Friday"
dayOfTheWeek(6) = "Saturday"
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim wDay As Integer
Set uidoc = ws.CurrentDocument
wDay = Weekday( Cdat(uidoc.FieldGetText("outDate")) )
Call uidoc.FieldSetText("DayOfWeek", dayOfTheWeek(wDay-1) )
End Sub
Result:
Upvotes: 1
Reputation: 2359
AFAIK, it isn't possible. And, what might even be worse in some cases: the Exiting-event isn't fired when the user types the Esc-key.
So: not possible... but... this wouldn't be Notes if there weren't a trick, albeit ugly. The only and very dirty way I can think of accomplishing what you want is by using a NotesTimer. Create a NotesTimer, set it to fire every second, to verify the previous and current content of your field. If its value is changed, you could try to do a Refresh or move the focus elsewhere.
Caution: NotesTimers are buggy as hell, at least,, they used to be. I assume moving the focus is safe, using Refreshing is only for the courageous.
A whole different solution is moving to XPages in the Notes Client, but I suppose you do not (yet) want to go there.
Upvotes: 1