XPages - Updating fields on a new document with onBlur

I have an xpage with a custom control on it containing a panel and within that panel, there are 6 fields. The first field, the user name, contains SSJS for the default value to put the current user name in there. The other fields all contain SSJS in their default values to do a lookup based on the name field and pull back other info like phone number, manager name etc.

I have added some SSJS to the onBlur event of the name field so that you can change the name in the field and the same lookups on the default values for the other fields run and they get their values updated to match the name in the username field. This works fine on a document that has been saved, but on new documents it’s as if the onBlur event doesn’t fire. I have tried hard coding a teext value to be assigned to one of the fields but this doesn’t happen, and neither does the lookups that I have written.

Below is the code that runs in the onBlur event for the Name field - can anyone tell me why this doesn’t run on a new document, yet the default value property for each of the fields all work when a new document is created:

var lukey=getComponent(“Name”).getValue();

var TelVal= @Subset(@DbLookup(@DbName(),“ZLAI-875HPQ”,lukey,4),-1);

if (TelVal!=undefined && TelVal!=null) {

getComponent("Tel_No").setValue(TelVal);

}

var mob = @DbLookup(@DbName(),“ZLAI-875HPQ”,lukey,5);

if (mob!=undefined && mob!=null) {

mob = @Subset(mob,-1);

getComponent("Mob_no").setValue(mob);

}

and the default value for the Mob_no field as above is this, which works fine on new documents:

var lukey=getComponent(“Name”).getValue();

var mlist= @DbLookup(@DbName(),“ZLAI-875HPQ”,lukey,5);

var mob = @Subset(mlist,-1);

return mob

Thanks in advance

Subject: Solved

Found the code I had was working correctly on a new XPage after I added a few of the fields in to test it. The onblur event was firing on new documents as well as saved documents, causing the related fields to be updated with their lookup values as expected.

After digging around, I found 2 date fields on the XPage having trouble a bit further down:

<xp:dateTimeHelper dojoType=“dijit.form.DateTextBox” id=“dateTimeHelper2”>

</xp:dateTimeHelper>

The fields on their own were working correctly but the validation on them was causing a problem. As soon as ‘Required’ was ticked, the Name field would not fire the onBlur event on new documents, causing the updates to the other fields to fail. If the document was an existing one, the onBlur event worked as expected. As soon as I took the ‘Required’ flag off the date fields, the onBlur event worked on new documents as well. No idea what this is all about? A bug perhaps?