Trigger LS agent from xpage

I am having problems triggering a lotusscript agent from a button on an xpage.

The code is placed in the onclick event of a button (Server) and looks like this:

var db:NotesDatabase = session.getDatabase(session.getServerName(), “web\modules\Product.nsf”);

var agent:NotesAgent = db.getAgent(“(updateProduct)”);

agent.runOnServer(document1.getDocument().getNoteID());

The agent will not run when I click the button. If I put the exact same code in an inputtext field (just for debugging purposes) and refresh the web page (xpage), the agent is run properly.

Same code for input field:

<xp:inputText id=“inputtext1”>xp:this.value<![CDATA[#{javascript:

var db:NotesDatabase = session.getDatabase(session.getServerName(), “web\modules\Product.nsf”);

var agent:NotesAgent = db.getAgent(“(updateProduct)”);

agent.runOnServer(document1.getDocument().getNoteID());

}]]></xp:this.value></xp:inputText>

What am I doing wrong here? I also tried using a submit-button with no luck.

Subject: Re: Trigger LS agent from xpage

I think that getDatabase should only need single \ rather than \

My other suggestion would be to use try…catch to check everything is getting set properly.

Regards

Paul

Subject: solution

The solution was to add createForm=“true” to the xp:view tag.