0
votes

I have a repeat control bound to a view data source.

In each row I have a link which when pressed I want to stamp that back-end document with a few field value changes and then save those changes. If an error on the save occurred I want to tell the user else I want the panel in which the repeat exists to refresh.

How can I grab the document associated with the row and test if the save worked?

3

3 Answers

0
votes

Try to call save on the document, not the view data source:

var doc:NotesDocument = data.getDocument();
var dt:NotesDateTime = session.createDateTime("Today");
dt.setNow();
doc.replaceItemValue("RcptDate", dt);
doc.replaceItemValue("RcptBy", sessionScope.get("customerBuyerName"));
doc.replaceItemValue("RcptStatus", "Receipted");
doc.save(true, false);
0
votes

Almost there but back-end document not changes :o(

My code for the link inside the repeat control ...

var doc:NotesDocument = data.getDocument();
var dt:NotesDateTime = session.createDateTime("Today");
dt.setNow();
doc.replaceItemValue("RcptDate", dt);
doc.replaceItemValue("RcptBy", sessionScope.get("customerBuyerName"));
doc.replaceItemValue("RcptStatus", "Receipted");

var dsName = "vdsReceipts.DATASOURCE";
var app = facesContext.getApplication();
var ds = app.getVariableResolver().resolveVariable(facesContext, dsName);
var ret = ds.save( facesContext, true );
0
votes

I'm curious if the script is getting a handle to the document. If you don't have var="data" in the repeat control, it never gets a handle to the doc.

The bigger issue is, you never issue a doc.Save, you save a different object. So, add the save to the top half of your script.

var doc:NotesDocument = data.getDocument();
var dt:NotesDateTime = session.createDateTime("Today");
dt.setNow();
doc.replaceItemValue("RcptDate", dt);
doc.replaceItemValue("RcptBy", sessionScope.get("customerBuyerName"));
doc.replaceItemValue("RcptStatus", "Receipted");
doc.Save();

Once you've actually saved it, then you can look at the datasource to see if it saved. If it's all in the same database, I think that would be overkill.

Hope that does it.