Hi All,
I’m a newbie for Domino and Javascript…
In my program, I want to create a button wich selects all documents in the view and sets a certain field to a fixed value.
I cannot use a formula, since the program is web-based.
How to do this with javascript?
thanks
Henny
Subject: javascript to change a field in all documents
Hi,
need some more details…
how you able to select all documents with the button onclick in web?
Thanks
Sreedhar
Subject: RE: javascript to change a field in all documents
Thanks for your reply!
I don’t know how to select all documents in the view and how to set a specific value to a field in all documents.
I can do this with a agent, but cannot get it to work from the web. I assume I have to get it done through javascript code?
henny
Subject: RE: javascript to change a field in all documents
Hi henny,
with my knowledge we can achieve that by two ways
- LotusScript agent.
a)Create Field name called “AgentName” in the Form.
b) Write following Code in Form WebQuerySave Event:
@Command([ToolsRunMacro]; AgentName)
c) Onclick of the button
document.forms[0].AgentName.value="Give the lotusscript agent name here"
document.forms[0].submit();
d) write lotuscript agent with the given name.(upadate the value to all documents)
2)AJAX (Asynchronous JavaScript AND XML)
Thanks,
Sreedhar
Subject: RE: javascript to change a field in all documents
No luck sofar…
Om my form, in WebQuerySave, I have put the command
@Command([ToolsRunMacro]; “ActionConfirmer”)
I have a agent called “ActionConfirmer”
This agents has the formula:
FIELD confirmation := “O”;
“”;
SELECT @All
On my webform I have created a field “AgentName”
and a button “ConfirmAll” with a hotspot
Onclick = Run Web Javascript
{
document.forms[0].AgentName.value = “ActionConfirmer”;
document.forms[0].submit();
}
But nothing happens… ;-(
What is wrong?
(Told you… I am a newbie… sorry)
Subject: RE: javascript to change a field in all documents
write lotus script code in the agent.
1.set Properties— Run time as OnEvent,List Selection,none.
2.Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim dccol As NotesDocument
Set db = session.CurrentDatabase
If ( Not db Is Nothing ) Then
Set view=db.GetView("ViewName")
Set doc=view.GetFirstDocument
While Not doc Is Nothing
doc.FieldName=Value
Call doc.save(True,True)
Set doc=view.GetNextDocument(doc)
Wend
End If
End Sub
You may get simple solution than this but i hope it will fullfill your requirement.
Thanks
Sreedhar
Subject: RE: javascript to change a field in all documents
SreedharThanks again for your replys and being so patient with me…
Sofar, I have done the next steps to set the field “confirmation” to “O” for all documents in the view “MyWebView” when the user clicks the button “Confirm” in the webform “MyWebForm”
- Created an agent called ActionConfirm
Trigger: On Event
Runtime: Agent List selection
Target: None
Run LotusScript:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim dccol As NotesDocument
Set db = session.CurrentDatabase
If ( Not db Is Nothing ) Then
Set view=db.GetView("MyWebView")
Set doc=view.GetFirstDocument
While Not doc Is Nothing
doc.confirmation="O"
Call doc.save(True,True)
Set doc=view.GetNextDocument(doc)
Wend
End If
End Sub
- In Webform “MyWebForm”
-
Created a field called “AgentName” , Text, Editable
-
Set WebQuerySave to " @Command([ToolsRunMacro]; AgentName) "
-
Created a hotspot around “Confirm” with the OnClick event:
Run: Web Javascript
code:
{
document.forms[0].AgentName.value = “ActionConfirm”;
document.forms[0].submit();
}
unfortuanly, nothing happens when I push “Confirm”
I understand your solution, so I must do something wrong…
Subject: RE: javascript to change a field in all documents
Hi henny,
I could see doc is not declared, and added error log this time in below code.
Sub Initialize
On Error Goto errorhandler
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim dccol As NotesDocument
Dim doc As NotesDocument
Set db = session.CurrentDatabase
If ( Not db Is Nothing ) Then
Set view=db.GetView("MyWebView")
Set doc=view.GetFirstDocument
While Not doc Is Nothing
doc.confirmation="O"
Call doc.save(True,True)
Set doc=view.GetNextDocument(doc)
Wend
End If
Exit Sub
errorhandler:
Print "Error is" & Error() & "at" & Erl
End Sub
Please run your agent in browser like this:
http://yourservername/database/agentname?OpenAgent
if you get any error let me know, else you can use the above code for your requirement.
Thanks
Sreedhar
Subject: RE: javascript to change a field in all documents
Create the first column having formula :“”
Now in the templateform for this view made a link by anchor tag:
i.e Select all
function selectAll()
{
var frm=document.forms[0];
for (var i=0;i<frm.elements.length;i++)
{
var e = frm.elements[i];
if (e.type=='checkbox')
{
e.checked=true
}
}
}
function clearAll()
{
var frm=document.forms[0];
for (var i=0;i<frm.elements.length;i++)
{
var e = frm.elements[i];
if (e.type=='checkbox')
{
e.checked=false
}
}