What I ended up doing may not be ideal but it will work in 90% of the cases at this shop.
- See if the user has synchronized their contacts to their mail file. If yes, then use their mail file as the source for their contacts.
- If no, then (at this company) attempt to locate the backed up server replica of their personal names.nsf. This won't always work since the server .nsf name isn't always consistent, but it's better than nothing.
- If neither of the above methods results in a hit, then display a "can't find personal nab" label in the name picker address book drop-down. I couldn't figure out how to hide the data provider if the personal contacts couldn't be found.
Improvement suggestions are always welcome.
In the afterPageLoad event:
if (session.isOnServer()){
/*
First, locate the current user's person document in the public NAB.
See if the user has synchronized their contacts from their personal names.nsf into their mail file.
If yes, then use that to display their personal contacts as a choice.
If no, then attempt to locate the server backup replica of their personal names.nsf.
*/
viewScope.personalNAB = "not found";
viewScope.personalNABTitle = "Personal Address Book Unavailable";
var userName:NotesName = session.createName(session.getEffectiveUserName());
var nab:NotesDatabase = session.getDatabase(session.getServerName(),"names.nsf",false);
if (nab){
var lkupView:NotesView = nab.getView("($VIMPeople)");
if (lkupView != null){
var personDoc:NotesDocument = lkupView.getDocumentByKey(userName.getAbbreviated(),true);
if (personDoc != null){
var mailServer:String = personDoc.getItemValueString("MailServer");
var mailFile:String = personDoc.getItemValueString("MailFile") + ".nsf";
var shortName:String = personDoc.getItemValueString("ShortName");
var nabBkp:String = "personal\\nab\\" + @LowerCase(shortName) + "names.nsf";
var tryNAB:NotesDatabase = session.getDatabase(mailServer,mailFile,false);
if (tryNAB){
var contactsView:NotesView = tryNAB.getView("($VIMPeople)");
if (contactsView){
if (contactsView.getAllEntries().getCount() > 0){
var personalNamesNSF:String = mailServer + "!!" + mailFile;
viewScope.personalNAB = personalNamesNSF;
viewScope.personalNABTitle = userName.getCommon() + "'s Address Book";
return "Synchronized contacts! " + personalNamesNSF;
}
}
};
//try to locate the backup of the personal nab
var bkpNAB:NotesDatabase = session.getDatabase(mailServer,nabBkp,false);
if (bkpNAB){
var personalNamesNSF:String = mailServer + "!!" + nabBkp;
viewScope.personalNAB = personalNamesNSF;
viewScope.personalNABTitle = userName.getCommon() + "'s Address Book";
return "Personal NAB backup! " + personalNamesNSF;
}else{
return "not synchronized & cannot locate pnab backup";
};
}else{
return "no person doc found";
};
}else{
return "no ($VIMPeople) view found in NAB";
};
}else{
return "NAB not found";
};
}else{
return "not on server";
};
Then, the namePicker:
<xe:namePicker id="namePicker1" for="fld_copyto_recipients">
<xe:this.dataProvider>
<xe:namePickerAggregator>
<xe:this.dataProviders>
<xe:dominoNABNamePicker addressBookSel="all"
nameList="peopleAndGroups">
</xe:dominoNABNamePicker>
<xe:dominoViewNamePicker labelColumn="$1"
viewName="($VIMPeople)" databaseName="#{javascript:viewScope.personalNAB;}"
label="#{javascript:viewScope.personalNABTitle;}">
</xe:dominoViewNamePicker>
</xe:this.dataProviders>
</xe:namePickerAggregator>
</xe:this.dataProvider>
</xe:namePicker>