使用LotusScript按钮保存复制文档并更改复制文档和原始文档的状态字段 [英] Save copy document and change status field for copy document and original document using lotusscript button

查看:177
本文介绍了使用LotusScript按钮保存复制文档并更改复制文档和原始文档的状态字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件和文件副本.我将TagNo用作两个文档的唯一ID. 我还具有状态"字段来区分每个文档,这些文档是活动",非活动",草稿"和锁定".我将在下面说明我的文档情况.

I have a document, and copy of document. I use TagNo as unique ID for both documents. I also have Status field to differentiate each document which is Active, Inactive, Draft, and Lock. I will explain below my document situation.

下面是我的文档,其中包含两个字段;标签号= PTagNo;状态= PStatus.情况如下.

Below here are my document with two field; Tag No = PTagNo; Status = PStatus. The situation as below.

  1. 对于原始文档,状态设置为有效".创建副本后,原始文档将更改为锁定",而复制文档"状态将更改为草稿". (为此我已经实现了.)

  1. For Original document, the status is set Active. When copy is created, Original document will change to Lock, And Copy document status change to Draft. (For this I already achieve.)

完成编辑后,我将更改草稿文档和原始文档的状态.当我将草稿文档另存为完成"时,会发生这种情况.我的草稿文档将是原始文档,而我的原始文档将是存档文档.因此,对于我的草稿文档,状态将更改为有效,而原始文档的状态将更改为无效.(尚未实现).

After done editing, I will change status for Draft document and Original document. This happen when I save Draft document as "Complete". My Draft document will be Original document while my Original document will be Archived document. So for my Draft document, status will change to Active while Original Document, status will change to Inactive.(Not achieve yet).

我粘贴我的保存代码,如下所示.

保存并完成

I paste my save code as below.

Save and Complete

Sub Click(Source As Button)
    Dim session As New NotesSession
    Dim db As NotesDatabase 
    Dim workspace As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Dim doc As NotesDocument
    Dim activeDoc As NotesDocument
    Dim view As NotesView
    Dim keys(1) As String

    '// Set database and doc
    Set db = session.CurrentDatabase
    Set uidoc = workspace.CurrentDocument
    Set doc = uidoc.Document    

    keys(0) = doc.PTagNo(0)
    keys(1) = "Lock"
    Set view = db.GetView("Computer")
    vpswd = Inputbox$("Pls input code to save :")

    If vpswd = "o" Then

        Set activeDoc= view.GetDocumentByKey(keys, True)
        If Not activeDoc Is Nothing Then
            If activeDoc.PStatus(0) = "Lock" Then
                activeDoc.DocumetId = doc.UniversalID
                Call activeDoc.ReplaceItemValue("PStatus", "Inactive")
                Call activeDoc.Save(True, False)
            End If
        End If
        Call uidoc.FieldSetText("PStatus" , "Active")
        Call uidoc.FieldSetText("SaveOptions" , "1")
        Call uidoc.Save
        Call uidoc.Close
    Else
        Msgbox "Wrong Code"
        Exit Sub
    End If  
End Sub

因此,我将GetDocumentByKey用于字段ptagno,但显示错误未设置对象变量".我是否使用了错误的功能?任何帮助将不胜感激.谢谢!

So I use GetDocumentByKey for field ptagno but it show error "Object variable not set". Did I use wrong function?. Any help will be appreciated. Thanks!

推荐答案

尚未设置变量ptagno-因此出现未设置对象变量"错误.您需要从字段PTagNo中读取值并将其分配给ptagno变量-或直接使用它.例如这样的

The variable ptagno has not been set - therefore the "Object variable not set" error. You need to read the value from the field PTagNo and assign it to the ptagno variable - or use it directly. For instance like this:

Set activeDoc= view.GetDocumentByKey(uidoc.FieldGetText("PTagNo"))

这篇关于使用LotusScript按钮保存复制文档并更改复制文档和原始文档的状态字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆