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

  • Home
  • SEARCH
  • 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 8104279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:47:41+00:00 2026-06-05T23:47:41+00:00

I have an Xpage page with a single Notes document datasource. After saving a

  • 0

I have an Xpage page with a single Notes document datasource.

After saving a document I want to (conditionally) trigger an agent. The agent takes some time to process and we don’t want the user to have to wait for the result, so it should be executed asynchronously.

I’ve managed to get it working from client side JS by using an XHR to the agent URL, but I would like to do it server side so I can control the “Next page” better. When using .run() or .runonserver() the client waits till the agent completes.

Any idea how I could trigger an agent (from SSJS) on PostSaveDocument without the client waiting for the result?

  • 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-06-05T23:47:43+00:00Added an answer on June 5, 2026 at 11:47 pm

    As Martin suggested I used the JobScheduler example on OpenNtf and modified it to suit my needs. Resulting code can be found below. Any comments or improvements are welcome.

    import java.security.AccessController;
    import java.security.PrivilegedAction;
    
    import lotus.domino.Agent;
    import lotus.domino.Database;
    
    import lotus.domino.NotesException;
    import lotus.domino.Session;
    
    import org.eclipse.core.runtime.IProgressMonitor;
    import org.eclipse.core.runtime.IStatus;
    import org.eclipse.core.runtime.Status;
    import org.eclipse.core.runtime.jobs.IJobChangeEvent;
    import org.eclipse.core.runtime.jobs.Job;
    import org.eclipse.core.runtime.jobs.JobChangeAdapter;
    
    import com.ibm.domino.xsp.module.nsf.ThreadSessionExecutor;
    
    public class JobRunner {
    
    public static void start(String dbPath, String agentName, String paramDocId) {
    
        synchronized (JobRunner.class) {
    
            runningJob = new ISPJob(dbPath, agentName, paramDocId);
            runningJob.addJobChangeListener(new JobChangeAdapter() {
                public void done(IJobChangeEvent event) {
                    System.out.println("Done event");
                    runningJob = null;
                }
            });
            AccessController.doPrivileged(new PrivilegedAction<Object>() {
                public Object run() {
                    runningJob.schedule();
                    return null;
                }
            });
    
        }
    }
    
    private static ISPJob runningJob;
    
    private static final class ISPJob extends Job {
    
        private ThreadSessionExecutor<IStatus> executor;
    
        private String docId;
        private String dbPath;
        private String agentName;
    
        public ISPJob(String paramDbPath, String paramAgentName, String paramDocId) {
            super(paramDocId);
    
            this.docId = paramDocId;
            this.dbPath = paramDbPath;
            this.agentName = paramAgentName;
    
            this.executor = new ThreadSessionExecutor<IStatus>() {
                @Override
                protected IStatus run(Session session) throws NotesException {
    
                    System.out.println("Job started" + docId);
                    System.out.println("   >> Session created: "
                            + session.getUserName() + ", Effective User:"
                            + session.getEffectiveUserName());
    
                        Database db = session.getDatabase(null,dbPath);
    
                        if (db != null) {
                            try {
                                if (!db.isOpen()) db.open();
                                if (db.isOpen()) {
                                    System.out.println("   >> Database opened: "
                                            + db.getTitle());
                                    Agent agent = db.getAgent(agentName);
                                    try {
                                        System.out.println("   >> Agent Started: " + agent.getName());
                                        agent.run(docId);
                                        System.out.println("   >> Agent Ran: " + agent.getName());
                                    } finally {
                                        agent.recycle();
                                    }
    
                                }
                            } finally {
                                db.recycle();                           
                            }
    
                    }
                    System.out.println("Job completed");
    
                    return Status.OK_STATUS;
                }
            };
    
        }
    
        protected IStatus run(IProgressMonitor monitor) {
            try {
                return executor.run();
            } catch (Exception ex) {
                return Status.CANCEL_STATUS;
            }
        }
    };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to change the view column header's value in Xpage... I have used
Have started playing with Xcode 4.2, and created a single page application using storyboard
I have an XPage which has just broken due to (what should have been)
I have a xPage application which shows list of emails of the currently logged
I have a xPage with following content: <xe:restService id=restService preventDojoStore=false> <xe:this.service> <xe:viewJsonService viewName=vwChartData contentType=text/json>
Using 8.5.3, I have an Xpage with a value picker that populates a dojo
in my xpage I have an editbox for user to enter the name of
In Xpage's CheckboxGroup, I have to get the values of both value and Label.
I'm witnessing some strange behaviour from Fluent nHibernate. I have two objects involved in
I have these three tables, page table page_id page_title 1 a content table content_id

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.