Dev2003
asked on
Javascript for changing field values when doc saved through web
Hi,
I have the following formula in the QuerySave event on a form in my database:
FIELD Comments:=Comments;
FIELD UpdateHistory:=UpdateHisto ry;
txt:=@If(Comments!= "";@Text(@Now)+" "+Comments+" ("+@Name([CN];@UserName)+ ")"+@NewLine+UpdateHistory ;UpdateHis tory);
@SetField("Comments";"");
@SetField("UpdateHistory"; txt)
the form contains two fields......
'Comments' is editable and allowing users to enter a message
'UpdateHistory' is computed with a value of 'UpdateHistory'.
When the document is saved in a client the comment is added to the 'UpdateHistory' field as well as some extra information. The 'Comments' field is then emptied ready for the next time somebody opens the document.
This code works perfect through a Notes client but it does not work over the web which i really need.
Can somebody supply a method of doing this, im guessing it will involve javascript.
cheers
I have the following formula in the QuerySave event on a form in my database:
FIELD Comments:=Comments;
FIELD UpdateHistory:=UpdateHisto
txt:=@If(Comments!= "";@Text(@Now)+" "+Comments+" ("+@Name([CN];@UserName)+ ")"+@NewLine+UpdateHistory
@SetField("Comments";"");
@SetField("UpdateHistory";
the form contains two fields......
'Comments' is editable and allowing users to enter a message
'UpdateHistory' is computed with a value of 'UpdateHistory'.
When the document is saved in a client the comment is added to the 'UpdateHistory' field as well as some extra information. The 'Comments' field is then emptied ready for the next time somebody opens the document.
This code works perfect through a Notes client but it does not work over the web which i really need.
Can somebody supply a method of doing this, im guessing it will involve javascript.
cheers
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
JavaScript is very handy when you want to validate field values in the browser without having to call the server to do that.
ASKER
ok have done that....but now when creating a new document through the web the document wont even save now.
the call in WebQuerySave is this:
@Command([ToolsRunMacro]; "UpdateHistory")
and the agent code is the same:
FIELD Comments:=Comments;
FIELD UpdateHistory:=UpdateHisto ry;
txt:=@If(Comments!= "";@Text(@Now)+" "+Comments+" ("+@Name([CN];@UserName)+ ")"+@NewLine+UpdateHistory ;UpdateHis tory);
@SetField("Comments";"");
@SetField("UpdateHistory"; txt);
SELECT @All
which is set to 'modify documents'
when the save button is clicked it closes the document but the doc does not appear in the view. it has not been saved.
the save button code is:
@If(@IsDocBeingEdited;@Do( @Command([ FileSave]) ;@Command( [FileClose Window])); "")
the call in WebQuerySave is this:
@Command([ToolsRunMacro]; "UpdateHistory")
and the agent code is the same:
FIELD Comments:=Comments;
FIELD UpdateHistory:=UpdateHisto
txt:=@If(Comments!= "";@Text(@Now)+" "+Comments+" ("+@Name([CN];@UserName)+ ")"+@NewLine+UpdateHistory
@SetField("Comments";"");
@SetField("UpdateHistory";
SELECT @All
which is set to 'modify documents'
when the save button is clicked it closes the document but the doc does not appear in the view. it has not been saved.
the save button code is:
@If(@IsDocBeingEdited;@Do(
Check the Designer Help database, you have to set a different type of agent. Sorry, got to go...
From that Help database:
Setting up a Web agent
Using the Agent Properties box, do the following:
- Check the "Shared" option when you create the agent.
- Set the agent trigger to "On event" and either "Agent list selection" or "Action menu selection."
- Set the agent target to either:
- "None" for agents that work on the current document such as those launched from
WebQueryOpen or WebQueryClose, or a form action or hotspot that works on fields
in the current document.
- "All documents in database" for agents that work on existing documents such as those
launched from the OpenAgent URL or a view action. The actual documents processed
depend on the agent code, for example, the SELECT statement in a formula or the
UnprocessedDocuments property in LotusScript.
- Check "Run as web user" on the Security tab to run the agent using the browser login name. Otherwise the agent runs with the rights of the agent signer.
Setting up a Web agent
Using the Agent Properties box, do the following:
- Check the "Shared" option when you create the agent.
- Set the agent trigger to "On event" and either "Agent list selection" or "Action menu selection."
- Set the agent target to either:
- "None" for agents that work on the current document such as those launched from
WebQueryOpen or WebQueryClose, or a form action or hotspot that works on fields
in the current document.
- "All documents in database" for agents that work on existing documents such as those
launched from the OpenAgent URL or a view action. The actual documents processed
depend on the agent code, for example, the SELECT statement in a formula or the
UnprocessedDocuments property in LotusScript.
- Check "Run as web user" on the Security tab to run the agent using the browser login name. Otherwise the agent runs with the rights of the agent signer.
ASKER
does anybody know what security settings and/or type the agent should have?
the database is only accessible from the web once a user has logged in
the database is only accessible from the web once a user has logged in
ASKER
thats it......
set the agent as:
shared
agent list selection
agent target as 'None'
and 'Run as a web user'
works perfectly,
thanks sjef
set the agent as:
shared
agent list selection
agent target as 'None'
and 'Run as a web user'
works perfectly,
thanks sjef
:)