Hi,
Have been struggling with this issue for a while now and am not sure what I am doing wrong.
I would like to add a document to a view, through java agent code.
The following is my code:
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
View tView = db.getView(“blah”);
ViewEntryCollection vecSPSS = tView.getAllEntries();
System.out.println("Number of entries before= " +vecSPSS.getCount());
//create new document
Document d = db.createDocument();
d.replaceItemValue(“beach”,“true”);
if(d.save(true, true))
{
System.out.println("the doc is saved");
System.out.println();
}
//add document to the viewentrycollection
vecSPSS.addEntry(d);
//try to retrieve entry
ViewEntry entry;
entry = vecSPSS.getFirstEntry();
System.out.println(“Parent view:” + vecSPSS.getParent());
System.out.println("Number of entries after = " + vecSPSS.getCount());
The number of entries in the collection before and after the document has been added as an entry is 0.
I have a view called blah, and a column in the view called beach, which has an underlying field called beach on a document. I am trying to create a document and populate that field called beach. But no document is getting saved in the view.
Please help! Am not sure what am doing wrong.
Many thanks,
Marise