?
Solved

Javascript for changing field values when doc saved through web

Posted on 2006-03-22
8
Medium Priority
?
219 Views
Last Modified: 2013-12-18
Hi,

I have the following formula in the QuerySave event on a form in my database:

FIELD Comments:=Comments;
FIELD UpdateHistory:=UpdateHistory;
txt:=@If(Comments!= "";@Text(@Now)+"  "+Comments+" ("+@Name([CN];@UserName)+ ")"+@NewLine+UpdateHistory;UpdateHistory);
@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
0
Comment
Question by:Dev2003
  • 5
  • 3
8 Comments
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 1000 total points
ID: 16255495
As you might know, a lot of events don't work from a browser. In this case, where you don't actually test anything, you can create an agent with the same code, and put the name of that agent in the call prepared under WebQuerySave. The agent will be executed when the web-form is saved.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16255582
JavaScript is very handy when you want to validate field values in the browser without having to call the server to do that.
0
 

Author Comment

by:Dev2003
ID: 16255670
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:=UpdateHistory;
txt:=@If(Comments!= "";@Text(@Now)+"  "+Comments+" ("+@Name([CN];@UserName)+ ")"+@NewLine+UpdateHistory;UpdateHistory);
@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([FileCloseWindow]));"")
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16255868
Check the Designer Help database, you have to set a different type of agent. Sorry, got to go...
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16257568
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.
0
 

Author Comment

by:Dev2003
ID: 16257572
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
0
 

Author Comment

by:Dev2003
ID: 16257637
thats it......

set the agent as:
 shared
agent list selection
agent target as 'None'
and 'Run as a web user'

works perfectly,

thanks sjef
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16257724
:)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Integration Management Part 2
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question