hreinart
asked on
Need a change of a front end agent to work in the web
hi,
the original problem is that there is a form where you enter a number (type text).
in the database there is 1 view showing relevant documents (selected by form used).
for the number entered allways only 1 document will be found (if you'd search manually ).
i have a script (see below) where this document is located and 1 field is replaced by a new value
and the document is saved.
my problem now is that (as far as i understand it) this agent is only usable in a notes front end.
...but i need to have it work in a browser.
my question for you is:
can you rewrite this to work in a browser (and tell me how to gwt it running)
or
may write e.g. something new in java (if this is more easy)
this is what i have sofar:
Sub Initialize
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim view As NotesView
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim item As NotesItem
Dim dateTime As New NotesDateTime( "" )
Set uidoc = workspace.CurrentDocument
Set db = session.CurrentDatabase
Set view = db.GetView ("($NX)" )
Dim key As String
Dim key2 As String
key = Cstr(uidoc.FieldGetText ("buchnummer"))
Set doc = view.GetDocumentByKey (key)
If Not (doc Is Nothing) Then
Call dateTime.SetNow
Set doc.rueckgabe = dateTime
Call doc.Save(True,True)
End If
Set db = session.CurrentDatabase
Set view = db.GetView ("($NR)" )
key2 = Cstr(uidoc.FieldGetText ("buchnummer"))
Set doc = view.GetDocumentByKey (key2)
If Not (doc Is Nothing) Then
Set Item = doc.ReplaceItemValue("stat us","vorha nden")
Call doc.Save(True,True)
End If
Call uidoc.Close
End Sub
the original problem is that there is a form where you enter a number (type text).
in the database there is 1 view showing relevant documents (selected by form used).
for the number entered allways only 1 document will be found (if you'd search manually ).
i have a script (see below) where this document is located and 1 field is replaced by a new value
and the document is saved.
my problem now is that (as far as i understand it) this agent is only usable in a notes front end.
...but i need to have it work in a browser.
my question for you is:
can you rewrite this to work in a browser (and tell me how to gwt it running)
or
may write e.g. something new in java (if this is more easy)
this is what i have sofar:
Sub Initialize
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim view As NotesView
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim item As NotesItem
Dim dateTime As New NotesDateTime( "" )
Set uidoc = workspace.CurrentDocument
Set db = session.CurrentDatabase
Set view = db.GetView ("($NX)" )
Dim key As String
Dim key2 As String
key = Cstr(uidoc.FieldGetText ("buchnummer"))
Set doc = view.GetDocumentByKey (key)
If Not (doc Is Nothing) Then
Call dateTime.SetNow
Set doc.rueckgabe = dateTime
Call doc.Save(True,True)
End If
Set db = session.CurrentDatabase
Set view = db.GetView ("($NR)" )
key2 = Cstr(uidoc.FieldGetText ("buchnummer"))
Set doc = view.GetDocumentByKey (key2)
If Not (doc Is Nothing) Then
Set Item = doc.ReplaceItemValue("stat
Call doc.Save(True,True)
End If
Call uidoc.Close
End Sub
You cannot use notesfrontend classes in web. What you have to do is have a form which displays the field and have a button with the javascript :
document.forms[0].submit()
and in the webquerysave of the form , have a agent with some name and this is the agent code:
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim item As NotesItem
Dim dateTime As New NotesDateTime( "" )
Set db = session.CurrentDatabase
Set curdoc = session.documentcontext
Set view = db.GetView ("($NX)" )
Dim key As String
Dim key2 As String
key = curdoc.buchnummer(0)
Set doc = view.GetDocumentByKey (key)
If Not (doc Is Nothing) Then
Call dateTime.SetNow
Set doc.rueckgabe = dateTime
Call doc.Save(True,True)
End If
Set db = session.CurrentDatabase
Set view = db.GetView ("($NR)" )
key2 = curdoc.buchnummer(0)
Set doc = view.GetDocumentByKey (key2)
If Not (doc Is Nothing) Then
Set Item = doc.ReplaceItemValue("stat us","vorha nden")
Call doc.Save(True,True)
End If
End Sub
document.forms[0].submit()
and in the webquerysave of the form , have a agent with some name and this is the agent code:
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim item As NotesItem
Dim dateTime As New NotesDateTime( "" )
Set db = session.CurrentDatabase
Set curdoc = session.documentcontext
Set view = db.GetView ("($NX)" )
Dim key As String
Dim key2 As String
key = curdoc.buchnummer(0)
Set doc = view.GetDocumentByKey (key)
If Not (doc Is Nothing) Then
Call dateTime.SetNow
Set doc.rueckgabe = dateTime
Call doc.Save(True,True)
End If
Set db = session.CurrentDatabase
Set view = db.GetView ("($NR)" )
key2 = curdoc.buchnummer(0)
Set doc = view.GetDocumentByKey (key2)
If Not (doc Is Nothing) Then
Set Item = doc.ReplaceItemValue("stat
Call doc.Save(True,True)
End If
End Sub
ASKER
p_partha:
i assume that the line with the word "button" is not used there, or?
i'll copy these lines only in a new agent:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim item As NotesItem
Dim dateTime As New NotesDateTime( "" )
Set db = session.CurrentDatabase
Set curdoc = session.documentcontext
Set view = db.GetView ("($NX)" )
Dim key As String
Dim key2 As String
key = curdoc.buchnummer(0)
Set doc = view.GetDocumentByKey (key)
If Not (doc Is Nothing) Then
Call dateTime.SetNow
Set doc.rueckgabe = dateTime
Call doc.Save(True,True)
End If
Set db = session.CurrentDatabase
Set view = db.GetView ("($NR)" )
key2 = curdoc.buchnummer(0)
Set doc = view.GetDocumentByKey (key2)
If Not (doc Is Nothing) Then
Set Item = doc.ReplaceItemValue("stat us","vorha nden")
Call doc.Save(True,True)
End If
is this correct?
any advise for the agent properties?
(when run? on which documents ...)
i assume that the line with the word "button" is not used there, or?
i'll copy these lines only in a new agent:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim item As NotesItem
Dim dateTime As New NotesDateTime( "" )
Set db = session.CurrentDatabase
Set curdoc = session.documentcontext
Set view = db.GetView ("($NX)" )
Dim key As String
Dim key2 As String
key = curdoc.buchnummer(0)
Set doc = view.GetDocumentByKey (key)
If Not (doc Is Nothing) Then
Call dateTime.SetNow
Set doc.rueckgabe = dateTime
Call doc.Save(True,True)
End If
Set db = session.CurrentDatabase
Set view = db.GetView ("($NR)" )
key2 = curdoc.buchnummer(0)
Set doc = view.GetDocumentByKey (key2)
If Not (doc Is Nothing) Then
Set Item = doc.ReplaceItemValue("stat
Call doc.Save(True,True)
End If
is this correct?
any advise for the agent properties?
(when run? on which documents ...)
ASKER
and regarding:
webquerysave of the form , have a agent
i only type there the name of the agent
ok?
thanks!
hreinart
webquerysave of the form , have a agent
i only type there the name of the agent
ok?
thanks!
hreinart
the agent should be run once@commands can be used and in the webquerysave of the form, give somethig liek this:
@command([toolsrunmacro];" <your agent name>")
Parhta
@command([toolsrunmacro];"
Parhta
ASKER
hi,
i did everything like instructed.
running it on the web i receive: form processed, but the field(s) aren't changed.
running the agent in the designer i get the error: object variable not set.
i started the debugger.
the code stops here :
key = curdoc.buchnummer(0)
the dubugger shows me that the variable curdoc exists and it's a variant.
(now my knowledge about script/designer is at the end/edge).
any idea what happend?
if possible i could send you the database.
thanks
hreinart
i did everything like instructed.
running it on the web i receive: form processed, but the field(s) aren't changed.
running the agent in the designer i get the error: object variable not set.
i started the debugger.
the code stops here :
key = curdoc.buchnummer(0)
the dubugger shows me that the variable curdoc exists and it's a variant.
(now my knowledge about script/designer is at the end/edge).
any idea what happend?
if possible i could send you the database.
thanks
hreinart
Form processed is what you will see when you submit a document, and the code willwork only in web as i have used documentcontext.
Have you given the key properly, as i don't see any problem with the code..
Partha
Have you given the key properly, as i don't see any problem with the code..
Partha
Also in the form , u need to have buchnummer field
Partha
Partha
ASKER
hi,
the code doesn't need to work with the notes client.
i just tried it to see if i can see something.
so this means that the notes error is not relevant here.
to test it i do a preview in my notes designer and press this button.
so for testing all is running on my client.
is that maybe a problem?
i have 1 filed called buchnumnmer.
it's a text field
thanks
hreinart
the code doesn't need to work with the notes client.
i just tried it to see if i can see something.
so this means that the notes error is not relevant here.
to test it i do a preview in my notes designer and press this button.
so for testing all is running on my client.
is that maybe a problem?
i have 1 filed called buchnumnmer.
it's a text field
thanks
hreinart
ASKER
Have you given the key properly
what could i check here?
what could i check here?
ASKER
maybe i send you the database?
ok, my id is in my profile..
ASKER
it's on the way, thanks.
Just add this line to your agent
Dim session As New notessession
Partha
Dim session As New notessession
Partha
ASKER
hi,
thanks for this information.
i'm out of the office now.
i'll return later and let you know via ee
thanks
harald
thanks for this information.
i'm out of the office now.
i'll return later and let you know via ee
thanks
harald
ASKER
hi,
sorry same result.
the document i test with buchnummer=1000 seems not to be touched at all.
it was modified yesterday.
when running this agent it should be modified today, or?
so unfortunatelly nothing changed here.
how did you test the database i sent you?
sorry same result.
the document i test with buchnummer=1000 seems not to be touched at all.
it was modified yesterday.
when running this agent it should be modified today, or?
so unfortunatelly nothing changed here.
how did you test the database i sent you?
ASKER
hi,
i looked in the notesdatabase.
there i find a lot of new documents with the form "rueckgabe".
in the end i don't need to these new documents.
the idea was to use this form to change an existing document (which should be found by the number enterd in the specified view).
in the end it's not a problem having these documents.
it's only unlucky that the agent doesn't find the document to change it.
any idea how it can get to run?
i looked in the notesdatabase.
there i find a lot of new documents with the form "rueckgabe".
in the end i don't need to these new documents.
the idea was to use this form to change an existing document (which should be found by the number enterd in the specified view).
in the end it's not a problem having these documents.
it's only unlucky that the agent doesn't find the document to change it.
any idea how it can get to run?
ASKER
hi,
i tested the database now on a domino server.
same result.
i have no idea why the agent doesn't work.
i tested the database now on a domino server.
same result.
i have no idea why the agent doesn't work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi i was out for a day.
try to test it this evening or tomorrow.
thanks sofar for your work. !!!
try to test it this evening or tomorrow.
thanks sofar for your work. !!!
ASKER
hi,
ijust now try you new code.
when entering a booknumber which is lent i receive this information in the browser:
This is the key given by me 597 Hurray document found , i am coming inside the field rueckgabe is being set to today
...but this document (only 1 exists) is not changed at all.
can you print out the document id which is found, that we could veryfy it's the correct one beeing found?
the document waslast changed on 6-10-2004, i tried this on 9-10-2004.
strange, or?
does the document has to be changed into an edit mode?
sorry for producing problems, but it's just not working
ijust now try you new code.
when entering a booknumber which is lent i receive this information in the browser:
This is the key given by me 597 Hurray document found , i am coming inside the field rueckgabe is being set to today
...but this document (only 1 exists) is not changed at all.
can you print out the document id which is found, that we could veryfy it's the correct one beeing found?
the document waslast changed on 6-10-2004, i tried this on 9-10-2004.
strange, or?
does the document has to be changed into an edit mode?
sorry for producing problems, but it's just not working
ASKER
to find out what happens i looked at the view "all documents" and.
whenever this agent run none of the existing documents changed the date&time of "last modified".
...but the database does.
so when running the agent the database changed the date&time to "now" .
this might be hint for you?
whenever this agent run none of the existing documents changed the date&time of "last modified".
...but the database does.
so when running the agent the database changed the date&time to "now" .
this might be hint for you?
ASKER
if i enter a number which doesn't exist at all i reived this:
This is the key given by me 7489 This is the second key given by me 7489
This is the key given by me 7489 This is the second key given by me 7489
ASKER
hi p_partha,
by looking at the new code from you i saw your comment about the access allowance.
i changed the acces allways to manager and it seems to work.
sorry that i didn't think of this before !
i say thank you and try it tomorrow to see which version is working.
then i'll accept your suggestion as the solution.
please have a look at my new questions with this database.
it's going to be completed.
thanks a lot again
hreinart
by looking at the new code from you i saw your comment about the access allowance.
i changed the acces allways to manager and it seems to work.
sorry that i didn't think of this before !
i say thank you and try it tomorrow to see which version is working.
then i'll accept your suggestion as the solution.
please have a look at my new questions with this database.
it's going to be completed.
thanks a lot again
hreinart
ASKER
hi p_partha,
everything runs fine...as far as i can judge this at the moment.
i'm very happy with your solution and want to say "thanks a lot" for it.
i increased the points to 180.
if it is not toom much work:
do you know a way to calculate how many days are between a given date (stored in a filed) and the value of @today?
thanks a gain
hreinart
everything runs fine...as far as i can judge this at the moment.
i'm very happy with your solution and want to say "thanks a lot" for it.
i increased the points to 180.
if it is not toom much work:
do you know a way to calculate how many days are between a given date (stored in a filed) and the value of @today?
thanks a gain
hreinart
Thx for the points and check this out for the date difference
replace yourdatefield with the fieldname
(@Today - @Date(<your date field>))/86400
Parta
replace yourdatefield with the fieldname
(@Today - @Date(<your date field>))/86400
Parta
ASKER
thanks a lot.
i'll open a new question in the next minute.
could you please have a look at it?
again something strange happens.....
i'll open a new question in the next minute.
could you please have a look at it?
again something strange happens.....
- get rid of the ui-objects and methods (uiworkspace, uidocument)
- use a correct method to get a handle to the current document
eg. set doc = session.documentcontext
(there are other ways)
cheers,
Tom