【发布时间】:2010-04-28 14:42:32
【问题描述】:
早安,
首先我会说我在一家小公司工作,没有接受过官方培训 记下我所知道的一切,我学会了购买试验和错误并使用其他人的代码。
应用程序:我们有一个已经运行了很长时间的采购订单数据库,并且人们输入供应商名称的年龄不同。现在我找到了一个进入所选表单并更改字段值的代码,这正是我需要的唯一问题 是单行吗?我要更新的字段大约有 5 行文本(公司名称、电话号码等),而原始程序员将所有信息放在一个字段中。
问题:下面链接的脚本中是否有一种方法可以使每个提示输入进入不同的行。我尝试了一些事情,但我想我可能遗漏了一些明显的东西。(如果我尝试 chr(10) ;chLv 我得到的只是两个相邻的值,或者用逗号分隔)
` 子初始化 Dim ws 作为新的 NotesUIWorkspace 暗淡会话作为新的 NotesSession 暗淡提示为字符串 将 fieldName 暗淡为字符串 将字段值调暗为字符串 将数据类型调暗为变体 将此数据类型调暗为字符串 将 fieldValues 变暗为变体 将 newFieldValues 调暗为变体 暗淡 db 作为 NotesDatabase Dim coll As NotesDocumentCollection 将 i 调暗为整数 将文档变暗为 NotesDocument 将项目暗淡为 NotesItem
prompt = "Please enter the name of the field to be updated"
fieldName = ws.Prompt(3, "Enter Field Name", prompt, "")
If fieldName = "" Then Exit Sub
If Instr(fieldName, " ") <> 0 Then
prompt = "Error! Field Names can't have spaces!"
Msgbox prompt, 16, "Error"
Exit Sub
End If
prompt = "Please enter the new value. For multiple values, separate with a colon."
Value1 =ws.Prompt(3, "Enter Field Value", prompt, "")
Value2= ws.Prompt(3, "Enter Field Value", prompt, "")
Fieldvalue=value1 + Chr(10) +value2
Redim dataTypes(5) As String
dataTypes(0) = "Text"
dataTypes(1) = "Number"
dataTypes(2) = "Date"
dataTypes(3) = "Readers"
dataTypes(4) = "Authors"
dataTypes(5) = "DELETE THIS FIELD"
prompt = "Choose the data type of the value(s)"
thisDataType = ws.Prompt(4, "Choose Data Type", prompt, dataTypes(0), dataTypes)
If thisDataType = "" Then Exit Sub
Set db = session.CurrentDatabase
Set coll = db.UnprocessedDocuments
fieldValues = Evaluate({@Explode("} & fieldValue & {"; ":")})
Select Case thisDataType
Case dataTypes(0) : Redim newFieldValues(Ubound(fieldValues)) As String
Case dataTypes(1) : Redim newFieldValues(Ubound(fieldValues)) As Double
Case dataTypes(2) : Redim newFieldValues(Ubound(fieldValues)) As Variant
Case dataTypes(3) : Redim newFieldValues(Ubound(fieldValues)) As String
Case dataTypes(4) : Redim newFieldValues(Ubound(fieldValues)) As String
End Select
For i = Lbound(fieldValues) To Ubound(fieldValues)
Select Case thisDataType
Case dataTypes(0) : newFieldValues(i) = Trim(fieldValues(i))
Case dataTypes(1) : newFieldValues(i) = Val(fieldValues(i))
Case dataTypes(2) : newFieldValues(i) = Cdat(fieldValues(i))
Case dataTypes(3) : newFieldValues(i) = Trim(fieldValues(i))
Case dataTypes(4) : newFieldValues(i) = Trim(fieldValues(i))
End Select
Next
Set doc = coll.GetFirstDocument
While Not doc Is Nothing
If thisDataType = "DELETE THIS FIELD" Then
If doc.HasItem(fieldName) Then Call doc.RemoveItem(fieldName)
Else
Call doc.ReplaceItemValue(fieldName, newFieldValues)
If thisDataType = dataTypes(3) Or thisDataType = dataTypes(4) Then
Set item = doc.GetFirstItem(fieldName)
If thisDataType = dataTypes(3) Then item.IsReaders = True
If thisDataType = dataTypes(4) Then item.IsAuthors = True
End If
End If
Call doc.Save(True, False)
Set doc = coll.GetNextDocument(doc)
Wend
结束子 '
抱歉,这篇文章很长,但不确定需要什么。第一次发帖求助,但我害怕我错过了相反的东西。
弗朗索瓦
【问题讨论】:
标签: lotus-notes lotus lotusscript