I have a dijit which displays a list of available contacts. Selected contacts then displayed in a view panel which was updating via a partial refresh until I added some code to check that duplicate contacts were not selected. Now the panel will not refresh. Any ideas?
Here's the SSJS which checks for duplciates. Sorry if I haven't explained this properlly or if there's a really simple solution to this 'problem' - total noob here.
var viewPanel=getComponent("viewPanel1");
var docIDs=viewPanel.getSelectedIds();
for(i=0 ; i < docIDs.length ; i++){
var docId = docIDs[i];
var doc:NotesDocument = database.getDocumentByID(docId);
// Get Contact Details from document
var FName = doc.getItemValueString("Org_Con_FirstName");
var LName = doc.getItemValueString("Org_Con_SurName");
var FullName = FName + " " + LName;
var Phone = doc.getItemValueString("Org_Con_Phone");
var Email = doc.getItemValueString("Org_Con_Email");
var Unid = doc.getUniversalID();
var checkView = database.getView("oppContacts");
var checkCollection = checkView.getAllDocumentsByKey(sessionScope.oppKey);
var checkCount = checkCollection.getCount();
var counter = 0;
if(checkCount != 0 ){
var checkDoc = checkCollection.getFirstDocument();
while(checkDoc!=null){
var checkEmail = checkDoc.getItemValueString("Email")
if(checkEmail==Email) counter = counter + 1;
var tempDoc = checkCollection.getNextDocument();
checkDoc.recycle();
checkDoc = tempDoc;
}
}
if(counter==0){
var oppContact = database.createDocument();
oppContact.replaceItemValue("Form","oppContact");
oppContact.appendItemValue("ContactName",FullName);
oppContact.appendItemValue("Email", Email);
oppContact.appendItemValue("Phone", Phone);
oppContact.appendItemValue("FullContact",Unid);
oppContact.appendItemValue("OpportunityKey", sessionScope.oppKey);
oppContact.save();
}
}