How do you copy a datetime field from the current document to a new document

倖福魔咒の 提交于 2019-12-25 05:32:32

问题


How do you copy a datetime field from the current document to a new document in Xpages, SSJS.

I am coping other fields like this

inheritDoc.appendItemValue("AbbreviatedCustomer",currentDocument.getValue("AbbreviatedCustomer"));
var item:NotesItem = inheritDoc.replaceItemValue("Author", n1); item.setNames(true);
item = inheritDoc.replaceItemValue("AuthorAccess", currentDocument.getValue("AuthorAccess")); item.setAuthors(true);

But I do not know how to copy a date field from the currentDocument to the inheritDoc. Thanks


回答1:


You don't have to care about data types copying fields (=Items) from one document to an other if you use

inheritDoc.copyItem(currentDocument.getDocument().getFirstItem("FieldName"))

or

inheritDoc.replaceItemValue("FieldName", currentDocument.getDocument().getFirstItem("FieldName"))

Fields in target document will have same data type, content and properties as in source document.




回答2:


Try using toJavaDate():

inheritDoc.replaceItemValue("DateField", currentDocument.getValue("DateField").toJavaDate());


来源:https://stackoverflow.com/questions/17075057/how-do-you-copy-a-datetime-field-from-the-current-document-to-a-new-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!