I have a Notes Database with a web front end. If a document in the database is modified on the web, the change is saved in the document. However, an agent that’s referenced in the WebQuerySave of the document’s form does not seem to run and it’s not apparent why.
Here’s some background …
-
The document is saved by a form action with the following formula: @Command([FileSave]);
-
The agent that’s referenced in the WebQuerySave contains only the following code:
Print “<script language=”“javascript”“>”
Print |alert(“This is a test.”);|
Print “”
-
The agent is Shared, has a trigger of ‘On Event’, and a target of ‘None’.
-
The form has a SaveOptions field that’s set to “1”.
-
The agent has the same security and access levels as another agent which runs successfully. (This other agent is run by the WebQuerySave of another form that a button with JavaScript in its ‘OnClick’ event to submit a document.)
Since the message is not displayed (item 2), this implies that either the WebQuerySave is not being reached or that the agent is simply not running. (Neither the client agent log nor the server log indicate that the agent has run.)
My question is this - shouldn’t the WebquerySave be invoked by the @Command([FileSave]). If not, can the WebQuerySave only be invoked by submitting a document with JavaScript?
Thanks.
Subject: WebQuerySave Question
@Command([FileSave]) is correct, and will run any WQS that can be run. (As an aside, I’ve never run across a situation where explicitly calling the submit() method in your own code is the best way to do things, since it skirts the _doClick() function and thus fails to feed Domino the information it wants from the __Click field.)
However – @Command([FileSave]), by itself, is “save and continue”. That is, the form should be re-opened in the browser. Now you have a conflict – do you want your alert printed back, or should Domino do what Domino is supposed to do? If you need the form to remain in the UI, then use a computed-for-display field on the form to carry your script. If you want to dump the document and print your script, then use @Command([FileSave]);@Command([FileCloseWindow]).
Subject: WebQuerySave Question
Is the agent set to Agent List Selection?
Subject: RE: WebQuerySave Question
Esther … yes, the agent was set to ‘Agent List Selection’ which I failed to mention.
Stan … the formula included two additional lines which I also didn’t mention as these didn’t seem to be factors. I expected the WebQuerySave to be invoked by @Command([FileSave]) and that the alert message in the agent could not possibly be impacted by subsequent commands. In its entirety, the formula is as follows:
@Command([FileSave]);
@Command([FileCloseWindow]);
@Command([OpenView];“(ViewName)”)
As you indicated, using only the first two lines allows the alert to be displayed and confirms that the agent referenced in the WebQuerySave runs as intended.
Thanks.
Subject: RE: WebQuerySave Question
So the issue is if you use only the first two lines, you can’t get to your view? Why not have the agent open the view as the very last thing it does?
Subject: RE: WebQuerySave Question
It can’t, directly. You’d need to expand the script printed back to include a URL change after the alert. (Square-bracket redirects have to be the only thing printed in the agent or they’ll be printed to an HTML page as literal text.)
Subject: RE: WebQuerySave Question
That’s what I meant. If he’s using javascript printed in his agent, he can do something like location.href=“mydb.nsf/myView?OpenView” after the alert.
Subject: RE: WebQuerySave Question
I know what you meant, and I’m every bit as guilty from time to time of assuming that the person I’m trying to help can fill in the blanks. You’ve covered my lapses a couple of times too. I suppose I should have made it clear that I was clarifying rather than correcting (so much).