1
votes

I am a newbie to xPages, not to Notes though. I have a type ahead field that works and it brings in the value needed. After that, I want to lookup information for the key they just entered and fill in fields on the form for that document. In the onChange event, I have the following code. I get the record but the setValue isn't working or at least it's not displaying on the xPage. Can someone help?

var path = database.getFilePath().split(database.getFileName())[0];
var lookupDB:NotesDatabase = session.getDatabase(database.getServer(), "db2.nsf");
 var vLookup:NotesView = lookupDB.getView("viewname");
var compID = getComponent("typeaheadfield").getValue()
var custDoc:NotesDocument = vLookup.getDocumentByKey(compID);
document1.setValue("fieldname", custDoc.getItemValue("custdocfieldname"));
1
I think you just miss the partial refresh of your form after the code is executed. Check the refresh/submit options of your onchange event.Oliver Busse
Thank you. I had partial update but the wrong field and only one field to update. I made it Full and it works (I have more than one field to update). Thanks.Mike Gonzalez
I will add this as an answer that you could acceptOliver Busse
Mike, even though you got it to work with a full update, note that Oliver in his answer is recommending (as am I) that you perform a partial refresh on the panel/DIV/Table that you want updated. Full refreshes create a flashing screen experience which is a poor UX. (Also don't forget to push the big green checkmark to accept his answer)Steve Zavocki
By the way: in the last line I'd check if you really found a document to prevent runtime exceptionsOliver Busse

1 Answers

2
votes

Make sure you do a partial refresh of your field or form. For the form you can define an ID for a sorrounding DIV and choose that ID as partial refresh ID in your onChange event.