将日期时间数组分配给 Domino 表单上的多值日期字段

发布于 2024-10-15 17:46:44 字数 866 浏览 4 评论 0原文

我正在从视图访问文档,读取日期时间字段,计算两个日期/时间值之间的天数,这两个日期/时间值分为四个类别。在每个类别中都有一个 for 循环,它将多个日期时间值添加到变体数组中。数组条目在 7 到 35 之间。循环之后,我喜欢将数组值分配给表单上的日期时间字段并保存文档。我使用了以下注释项:

Dim nitem as Notesitem  
Set nitem = doc.ReplaceItemValue("Datefield", dtArray)  

它不起作用。我使用了 doc.ReplaceItemValue "Datefield, dtArray 这个也不起作用。代理运行后该字段为空。我声明了一个变量并将数组分配给该变量,然后将变量分配给表单上的字段:

Dim var1 as variant
var1 = dtArray
doc.datefield = Var1

仍然没有运气查看分配给文档中字段的数组值

这是主循环

Redim dateArray(0)
For i=0 to NumberofDays -1
    set notesitem = dtitem.DateTimeValue
    call notesitem.AdjustDay(i)
    set dateArray(i) = notesitem
    Redim preserve dateArray(i+1)
Next


doc.replaceitemvalue "Datefield", dateArray

call doc.save(false, true)
erase dateArray

为什么代理运行后文档中的日期字段是空白的?我应该如何更改它以获得结果?声明如下:

谢谢

I am accessing a document from a view, read a datetime field, figure out number of days between two date/time values which fall into four categories. In each category there is a for loop which add number of datetime values to an array of variant. Array entries are between seven and 35. After the loop I like to assign the array values to a date time field on the form and save the document. I have used Notes item as follow:

Dim nitem as Notesitem  
Set nitem = doc.ReplaceItemValue("Datefield", dtArray)  

It didn't work. I used doc.ReplaceItemValue "Datefield, dtArray this one didn't work either. The field is blank after the agent runs. I declared a variable and assigned the array to the variable then assigned variable to the field on the form:

Dim var1 as variant
var1 = dtArray
doc.datefield = Var1

Still no luck to see array values assigned to the field in the document

Here is main loop

Redim dateArray(0)
For i=0 to NumberofDays -1
    set notesitem = dtitem.DateTimeValue
    call notesitem.AdjustDay(i)
    set dateArray(i) = notesitem
    Redim preserve dateArray(i+1)
Next


doc.replaceitemvalue "Datefield", dateArray

call doc.save(false, true)
erase dateArray

Why after the agent runs datefield in the documents are blank? What is missing? How should I change this to get result. Is it possible to add a delemiter to the assignment statement as follows:

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

叹沉浮 2024-10-22 17:46:44

当您使用 NotesItemNotesDateTime 类时,我认为使用 NotesItem DateTimeValue 会带来更多乐趣代码>属性。这是读/写,并返回(或期望)一个 NotesDateTime 对象。

例如,如果您有一个名为“dt”的 NotesDateTime 实例,则可以通过以下方式将其写回名为“YourDT”的字段:

Dim itDT as NotesItem
Dim dt as New NotesDateTime
' Instantiate itDT and dt
...
Set itDT.DateTimeValue = dt

因此,您应该能够获取 数组>NotesDateTime 对象,并使用此方法将其写回相关字段。

When you're playing around with NotesItem and the NotesDateTime classes, I think you will have more joy using the NotesItem DateTimeValue property. This is read / write, and returns (or expects) a NotesDateTime object.

For example, if you have a NotesDateTime instance called "dt", this is how you would write it back to a field called "YourDT":

Dim itDT as NotesItem
Dim dt as New NotesDateTime
' Instantiate itDT and dt
...
Set itDT.DateTimeValue = dt

So, you should be able to take your array of NotesDateTime objects, and write it back to the relevant field using this approach.

自我难过 2024-10-22 17:46:44

从数组中分配 dateTime 字段的最简单方法是:

SimpleDateFormat smdf = new SimpleDateFormat();
smdf.applyPattern("dd.MM.yyyy");
Vector dates = new Vector();
for (Date dt: dateArray) {
       dates.addElement(smdf.formatter(dt));
}; 
doc.replaceItemValue("dateField", dates);

The simplest way to assign dateTime field from an array is:

SimpleDateFormat smdf = new SimpleDateFormat();
smdf.applyPattern("dd.MM.yyyy");
Vector dates = new Vector();
for (Date dt: dateArray) {
       dates.addElement(smdf.formatter(dt));
}; 
doc.replaceItemValue("dateField", dates);
临风闻羌笛 2024-10-22 17:46:44

这对您来说很难排除故障,因为您没有提供原始源代码。您尝试使用方法的方式有点奇怪。

以下是您正在尝试执行的操作的基本操作。日期时间字段有点棘手,但您可以使用变量数组来设置它们。

    Dim i As Integer
    Dim vDateArr() As Variant
    Dim itDate As notesItem
    ' setup date array.
    ' .........
    ' .........
    ' Now get the date field to be updated from the document
    Set itDate = doc.GetFirstItem("fieldName")
    ' loop through the array of values and make sure they're date time
    For i=0 To numberOfDays - 1
       ' ensure that the array has date type values. V_DATE is a constant defined 
       ' in LSConst.lss. V_DATE = 7, so you can still write the following line as
       ' If Datatype(vDateArr(i)) <> 7 then
       If Datatype(vDateArr(i)) <> V_DATE Then
           vDate = Cdat(vDateArr(i))
       End If
       vDateArr(i) = vDate
    Next
    ' assign the array back onto the itDate field. Even if the field is not 
    ' already a dateTime type. Assigning the array this way will make it so.
    itDate.Values = vDateArr
    Call doc.Save(True, False)

我发现在这种情况下最好使用基元,而不是对象。这里发生的事情是我确保日期值存储为日期时间值。然后将数组分配给字段,然后保存文档。有多种方法可以做到这一点,但当您想要将特定类型的数组推入字段时,这是我的首选方法。如果您可以发布原始代码,那么更正您的代码会更容易。

This is tricky to trouble shoot for you, as you haven't provided the original source code. The way your trying to use methods is a bit strange.

Below is a basic go at what you're trying to do. DateTime fields are a bit tricky, but you can set them using variant arrays.

    Dim i As Integer
    Dim vDateArr() As Variant
    Dim itDate As notesItem
    ' setup date array.
    ' .........
    ' .........
    ' Now get the date field to be updated from the document
    Set itDate = doc.GetFirstItem("fieldName")
    ' loop through the array of values and make sure they're date time
    For i=0 To numberOfDays - 1
       ' ensure that the array has date type values. V_DATE is a constant defined 
       ' in LSConst.lss. V_DATE = 7, so you can still write the following line as
       ' If Datatype(vDateArr(i)) <> 7 then
       If Datatype(vDateArr(i)) <> V_DATE Then
           vDate = Cdat(vDateArr(i))
       End If
       vDateArr(i) = vDate
    Next
    ' assign the array back onto the itDate field. Even if the field is not 
    ' already a dateTime type. Assigning the array this way will make it so.
    itDate.Values = vDateArr
    Call doc.Save(True, False)

I find it best to work with primitives, not objects in this case. What's happening here is that I am ensuring that the date values are stored as a dateTime value. Then assigning the array to the field and then saving the document. There are a number of ways to do this, but this is my preferred way when you want to push an array of a specific type into a field. If you can post the original code, it would be easier to correct your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文