【发布时间】:2015-07-08 17:44:43
【问题描述】:
我有一个可以打开 xpage 的视图控件。当 xpage 打开时,会触发 beforePageLoad 事件。它检查正在打开的文档的特定字段中是否有任何附件,如果有,它会返回文件名列表。这工作正常。然后,我被要求更改视图的一列中显示的内容。我向视图控件的数据部分添加了一个变量来访问该行。然后我在列中添加了一些 javascript 以不同方式显示数据。那行得通,它根据需要显示数据。但是,当我现在单击链接打开 xpage 时,触发 beforePageLoad 事件时,那里的代码现在失败了。它在星号行出现此错误失败:
Script interpreter error, line=9, col=49: 'closureField' is null at
[/Function_ReturnListOfClosureAttachmentNames.jss].ReturnListOfClosureAttachmentNames(CCEB1351591847CB85257E7C005EF68C)
function ReturnListOfClosureAttachmentNames(ltDoc ){
var closureAttachmentFileNames = "";
var thisLT = ltDoc;
var closureField:NotesRichTextItem = thisLT.getFirstItem("closeAttachments");
*>>> var eos:java.util.Vector = closureField.getEmbeddedObjects();<<<
var eosi:java.util.Iterator = eos.iterator();
while (eosi.hasNext()) {
var eo:NotesEmbeddedObject = eosi.next();
closureAttachmentFileNames = closureAttachmentFileNames +","+eo.getName();
}
return closureAttachmentFileNames;
}
我从 beforePageLoad 事件中调用此函数并将其传递给 currentDocument.getDocument()。我想我可能在将列显示数据从“视图列”更改为“计算值”后丢失了文档上下文,但我不确定。任何想法将不胜感激。
谢谢!
克莱姆
【问题讨论】:
-
克莱姆,你能在调用函数之前包含你的 beforePageLoad SSJS。我敢打赌你是对的。还包括视图控件的数据部分代码。
-
嗨史蒂夫...嗯,这只是一个单行:viewScope.closureAttachments = ReturnListOfClosureAttachmentNames(currentDocument.getDocument());
-
视图控件的数据部分只是指向一个 Notes 视图。没有什么花哨。视图列代码如下并且完美运行: var status = rec.getColumnValue("statusOfIssue"); if (status == "Pending Closure" || status == "Pending Closure Assignment" || status == "Closed"){ return "LabWare Recommended"; }else{ 返回状态; }
-
感谢您添加。您是否尝试过在 SSJS 函数中获取当前文档而不是传入它?
-
这一切都很奇怪。这是另一个想法:在 beforePageLoad 中获取当前文档的 UNID(仅适用于保存的文档)并分配给 var。将该 var 作为参数传递给函数。在函数中,使用该 UNID 获取文档。我看不出你怎么会在这里出错。
标签: xpages