Xpage中的后端代理的执行

 

 

var agent=database.getAgent("AgentDemo");
unid=document1.getDocument().getNoteID();
agent.run(unid);

 

将文档的NotesID做为参数传递给后端代理以方便后端代理在执行时操作要处理的文档。

 

注:以上程序是运行在数据源的postSaveDocument事件上

 

 

 

后端代理的程序如下:

    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim doc As NotesDocument
    Dim agent As NotesAgent
   
    Dim noteid As String
   
    Set db=session.Currentdatabase
    Set agent=session.Currentagent

     '返回NotesID通过用户传入的参数ID
      noteid=agent.Parameterdocid
   
    Dim memo As String
    '获得要操作的文档
    Set doc=db.Getdocumentbyid(Noteid)
   
    If doc Is Nothing Then
        Print"Document not found"
        Exit sub
    End If
   
    If doc.a2(0)="" Or doc.a3(0)="" Then
        memo="信息不全,没有部门或电话"
    Else
        memo="个人信息"+doc.a2(0)+"and"+doc.a3(0)
    End If
   
    Call doc.Replaceitemvalue("Memo", memo)
   
    Call doc.Save(true, true)

你可能感兴趣的:(Lotus,文档,string,session,电话)