title: Run "Repeatagent" on Xpage
body: <p>I would like the following agent to run onclick of a button,  the agents job is to check if the user wants a document(in this case a Journal Entry) to be date repetetive. So I am trying to create multiple documents at once. I had a simular Lotusscript running in the Notes Application which seemed to work fine but I dont know how to run it on my Xpage.
  Code:</p>
  
  <pre><code>Sub Initialize
  Dim session As New NotesSession 
  Dim db As NotesDatabase
  Dim UIdoc As NotesUIDocument
  Dim doc As NotesDocument 
  Dim Workspace As New NotesUIWorkspace
  Set db = session.CurrentDatabase
  Set UIdoc = workspace.CurrentDocument
  Dim Radio As String
  Dim String1 As String
  Dim Counter As Integer
  Print("Repeat Agent Triggered and Variables Initialized")
  String1 = UIdoc.FieldGetText("SubjectTX")
  Radio = UIdoc.FieldGetText( "RepeatValueTX" )
  Dim ret As Variant 
  Dim Newdate As New NotesDateTime(UIdoc.FieldGetText("DiaryDateDT")) 
  Print(Radio)
  Print(String1)
  Print("Select Case...")
  Select Case Radio
      Case "Day": 
          Print("Case Day in use")
          For Counter = 1 To 7
              Call Newdate.AdjustDay( 1 )
              Set doc = db.CreateDocument
              doc.SubjectTX = "Day Revision " + String1
              doc.DiaryDateDT = NewDate
              Call doc.Save( True, True )
          Next
      Case "Week":
          Print("Case Week in use")
          For Counter = 1 To 4
              Call Newdate.AdjustDay( 7 )
              Set doc = db.CreateDocument
              doc.SubjectTX = "Week Revision:" + String1
              doc.DiaryDateDT = NewDate
              Call doc.Save( True, True )
          Next
      Case Else: 
          Print("No Case or Saving and Closing")
  End Select
     Print("exited switch, Saving and Closing now")
     Call UIdoc.Save()
     Call UIdoc.Close()
  </code></pre>
  
  <p>End Sub</p>
  
  <p>The Agent is set to "Allow restricted operations" , "Run as Web user" , Target:none, "Agent List selection".</p>
  
  <p>The Javascript supposed to execute the Agent</p>
  
  <pre><code>database.getAgent("Repeatagent").run()
  </code></pre>
  
  <p>maybe I am missing something essential here, if there is a better way to do this please let me know!</p>
  
  <p>I am fairly new to notes and sort of bunched this together from the help menu so if you have a solution please try to explain very extensive.</p>
  
  <p>Thank you </p>