onChange event, works when exiting the field not 'onChange'

Hi,I have a Names field, it is ‘Use Address Dialogue on choices’, i

Default Value:@Name([CN];@UserName)

Input Translation:@Name([CN];@ThisValue)

Input Validation:Namet :=@IfError(@DbLookup(“Notes”:“NoCache”;“86256395:004EDFB0”;“($NamesFieldLookup)”;Name4;“FullName”);“Error”);

Name :=@Name([CN];Namet);

@If(Name4=“”;@Failure("Please enter a name for the " + Role4 + “.”);

@If(Namet=“Error”;@Failure("Please enter a valid name for the " + role4 + “.”);@Success))

OnChange event:

Sub Onchange(Source As Field)

Dim ws As New NotesUiWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = ws.CurrentDocument

Dim Doc As NotesDocument

Set doc = uidoc.Document

Dim Eval As Variant

Dim session As New NotesSession

'string$ = notesName.Common

'doc.CNName4=Session.CreateName(Name4.Common)

Dim CNName4 As Variant

CNName4=Evaluate(|@Name([CN];Name4)|,doc)

doc.CNName4=CNName4



Eval=Evaluate(|@DbLookup("Notes":"Cache";"86256395:004EDFB0";"($Users)";CNName4;"PIN")|,doc)

If Eval(0) <>"" Then

	Dim Evals As String

	Evals = Cstr(Eval(0))

	doc.tmpValue=Evals

	Eval1=Evaluate(|@DbLookup("Notes":"Cache";"86256395:004EDFB0";"(PeopleByPin)"; tmpValue;9)|,doc)

	ManagerKey = "UK" & Right(Cstr(Eval1(0)),6) 

	doc.tmpValue2=ManagerKey	

	ManagerName=Evaluate(|@Name([CN];@DbLookup("Notes":"Cache";"86256395:004EDFB0";"(PeopleByPin)";tmpValue2 ;6))|,doc)

	ManagerNames = Cstr(ManagerName(0))

	doc.Boss=ManagerNames

	Call uidoc.Reload

'Call uidoc.FieldSetText("Boss",ManagerNames)

'Call uidoc.Refresh

	

	doc.RemoveItem( "tmpValue" )

	doc.RemoveItem("tmpValue2" )

	doc.RemoveItem("CNName4")

'ManagerID :=

'ManagerKey := "UK" + @Right(ManagerID;6);

'ManagerName := (Cstr(Eval1(0));6);

'@If(@Name([CN];@UserName)="Andrew L Butler";"Andrew L Butler";ManagerName)

Else

	Exit Sub

End If

End Sub

But…the onChange event only works when you exit the field or save the document - I want it to work right away.

I cannot change the field style to native OS.

Any ideas?

Thanks…

Subject: onChange event, works when exiting the field not ‘onChange’

Yep. The code in onChange event gets executed only if the cursor is out of field. The order in which this event works is:

After making a change in the field,

  1. When tabbed out of the field, the events execute in the following order: onBlur and then Exiting and finally onChange(only after those two events).

  2. Considering the above order, if onBlur contains code for saving the uidoc, then only Exiting event code will be executed. The code in onChange will be ignored.

  3. Instead of uidoc.save, if onBlur contains code for uidoc refresh, then the order of execution is Exiting and then onChange.

  4. If uidoc is refreshed manually by pressing F9 on keyboard or after the change directly go to menu and click on File–> Save, this is the only time onChange event fires first ignoring onBlur and Exiting.

Finally in order to execute the code in onChange event, user has to come out of the field or refresh document. But, like the way I mentioned above, that if other events contain code, those events execute first and then finally, onChange, except upon manual refresh and save.

Subject: RE: onChange event, works when exiting the field not ‘onChange’

It’s working as intended. If you were the software developer how would you capture that the user has finished entering text to fire off that event?

You can fire off a validation on each keystroke, but that is usually counter-intuitive unless you’re building a web-based type-ahead.

Subject: RE: onChange event, works when exiting the field not ‘onChange’

Hi,Just wondered if someone had a work around.

It’s a silly name for an event, ‘onChange’ that actually occours when exiting the field…

I kinda know it doesn’t work - what I was after was some way round it…