XPages:在ssjs中创建当前的Datetime并保存到Datetime Notes表单字段

mik*_*_x_ 0 datetime lotus-notes lotus-domino xpages xpages-ssjs

我发现将日期存储在注释形式的Datetime字段中的唯一方法是:

theDoc2.replaceItemValue("lastAccess",session.createDateTime("Today"));
Run Code Online (Sandbox Code Playgroud)

但这只会创建一个Date,而不是DateTime。另外,我不想创建像“今天12”这样的静态时间,但我希望动态地使用当前日期时间。

使用这个我得到一个错误(调用方法NotesDocument.replaceItemValue(string,Date)null发生异常):

theDoc2.replaceItemValue("lastAccess",@Now());
Run Code Online (Sandbox Code Playgroud)

并使用此,窗体字段从日期/时间更改为文本数据类型,我想保留日期/时间类型:

theDoc2.replaceItemValue("lastAccess",@Now().toLocaleString);
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Lot*_*ler 5

刚刚尝试一下:

如您所写,.replaceItemValue("fieldName", @Now())将引发错误。

但是,我可以使用它

.replaceItemValue("fieldName", session.createDateTime(@Now()))
Run Code Online (Sandbox Code Playgroud)

在这种情况下,该值将作为“时间/日期”存储在“注释”字段中,其中包含所有必需的组件,如

17.01.2014 12:45:51 CET
Run Code Online (Sandbox Code Playgroud)

从我所看到的,两者之间的区别是@Now()返回Date 数据类型,而session.createDateTime()返回NotesDateTime对象

另一方面,对我来说,它也可以使用您的原始方法:

session.createDateTime("Today")
Run Code Online (Sandbox Code Playgroud)

不知道是什么原因导致您出现问题;您对xpage上的字段有可编辑的表示吗?如果是这样,是否启用了某种转换器,可以在提交期间进行一些过滤?