Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6984465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:33:10+00:00 2026-05-27T18:33:10+00:00

I have an agent with the following code: Sub Initialize MessageBox AgentStart Print AgentStart

  • 0

I have an agent with the following code:

Sub Initialize
    MessageBox "AgentStart"
    Print "AgentStart"

    Dim ws As New NotesUIWorkspace
    Dim s As New NotesSession
    Dim db As NotesDatabase
    Dim vItemsBySupplierSpec As NotesView
    Dim Doc As NotesDocument
    Dim DocsWithSameSupplierSpec As NotesDocumentCollection
    Dim MatchingDoc As NotesDocument
    Set Doc = ws.CurrentDocument.Document

    If Len(Doc.ItemSupplierSpecification(0)) > 0 Then
        ' Check that this supplier specification isn't use anywhere else.'
        Set db = s.CurrentDatabase
        Set vItemsBySupplierSpec = db.GetView("vItemsBySupplierSpec")

        Set DocsWithSameSupplierSpec = vItemsBySupplierSpec.GetAllDocumentsByKey(Doc.ItemSupplierSpecification(0), True)
        Set MatchingDoc = DocsWithSameSupplierSpec.GetFirstDocument

        Dim ItemsString As String

        ItemsString = "The following items already use this supplier specification." + Chr(10) + Chr(10) + _
        "You should check whether you really want to raise another, or use the existing one." + Chr(10)


        While Not MatchingDoc Is Nothing
            ItemsString = ItemsString + Chr(10) + MatchingDoc.ItemNumber(0) + " - " + MatchingDoc.ItemDescription(0)
            Set MatchingDoc = DocsWithSameSupplierSpec.GetNextDocument(MatchingDoc)
        Wend

        If DocsWithSameSupplierSpec.Count > 0 Then
            Print ItemsString
            MsgBox ItemsString
        End If
    End If
End Sub

Previously it was ran within the onchange event of a field in a form.

I’ve now created an agent as above, and want to invoke it from the ui both in lotus script and @formula language.

Dim s As New NotesSession
Dim db As NotesDatabase

Set db = s.CurrentDatabase

Dim CheckSupplierSpec As NotesAgent
Set CheckSupplierSpec = db.GetAgent("CheckSupplierSpec")

If CheckSupplierSpec.Run = 0 Then
    MessageBox "Agent Ran"
End If

I created the agent as trigger, on event – menu selection, target: none, options: shared. I do get the “Agent Ran” messagebox.

I’ve tried this however although checking the agent it says it last ran when the onchange event was fired i don’t get any message boxes or print output.

The first question, is why isn’t the messagebox working? the 2nd question is how can i get the current document?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:33:11+00:00Added an answer on May 27, 2026 at 6:33 pm

    It would help to know why you moved it from onChange to an agent, but I think there are ways to do what you want to do.

    You mentioned invoking the agent from formula language- I was able to display a Messagebox calling the agent this way:

    @Command([RunAgent];"CheckSupplierSpec")
    

    Another option would be doing your agent as a Java agent. This gives you access to Java UI classes that will display even if called by NotesAgent.Run. Example here.

    If you don’t want to rework the entire agent in Java, you can use LS2J to access the Java UI classes. For example, you could create a Java script library called “Java Messagebox”:

    import javax.swing.JOptionPane;
    
    public class JavaMessagebox {
    
        public void Messagebox (String message) {
            JOptionPane.showMessageDialog(null, message);
        }
    
    }
    

    and then call it from a LotusScript agent like this:

    Use "Java Messagebox"
    Uselsx "*javacon"
    Sub Initialize
        Dim mySession  As JavaSession
        Dim myClass As JavaClass
        Dim myObject As JavaObject
        Set mySession = New JavaSession()
        Set myClass = mySession.GetClass("JavaMessagebox")
        Set myObject = myClass.CreateObject()
        myObject.Messagebox(|This is my Java messagebox!|)
    End Sub
    

    For a more sophisticated example using a Java AWT component that uses the native look and feel of your operating system, I recommend studying Julian Robichaux’s LS2J Examples Database. His StatusBox example is non-modal but you can find the parameter to make it modal here if needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code, thanks to another SO question/answer: page = agent.page.search(table tbody
I have a site with the following robots.txt in the root: User-agent: * Disabled:
I have the following code which is parsing a HTML table as simply as
I have the following code: curl_setopt($ch, CURLOPT_URL, $host); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
I have the following code which runs fine on my computer but fails online:
I have the following SQL code: select val.PersonNo, val.event_time, clg.number_dialed from vicidial_agent_log val join
In my jsp page, I have in the <head> tag, the following code: <script
In the following code, we have to join the url.path and url.query ourselves using
I have the following JS code $('#dialog').dialog({ ... buttons: { OK: function() { callAjax({some:param});
I have following code in my asp.net MVC3 application: string msg = Beginning report

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.