Solved

Need a change of a front end agent to work in the web

Posted on 2004-10-06
27
235 Views
Last Modified: 2013-12-18
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("status","vorhanden")
            Call doc.Save(True,True)
      End If
      Call uidoc.Close
End Sub

0
Comment
Question by:hreinart
  • 18
  • 8
27 Comments
 
LVL 15

Expert Comment

by:Bozzie4
ID: 12239761
Yeah this agent is only useable in the notes client.  You must rewrite it :
- 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
0
 
LVL 14

Expert Comment

by:p_partha
ID: 12239820
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("status","vorhanden")
            Call doc.Save(True,True)
      End If
End Sub
0
 

Author Comment

by:hreinart
ID: 12240145
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("status","vorhanden")
          Call doc.Save(True,True)
     End If


is this correct?

any advise for the agent properties?
(when run?  on which documents ...)
0
 

Author Comment

by:hreinart
ID: 12240151
and regarding:

webquerysave of the form , have a agent


i only type there the name of the agent

ok?


thanks!
hreinart
0
 
LVL 14

Expert Comment

by:p_partha
ID: 12240941
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
0
 

Author Comment

by:hreinart
ID: 12241802
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
0
 
LVL 14

Expert Comment

by:p_partha
ID: 12241823
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

0
 
LVL 14

Expert Comment

by:p_partha
ID: 12241830
Also in the form , u need to have buchnummer field

Partha
0
 

Author Comment

by:hreinart
ID: 12247041
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
0
 

Author Comment

by:hreinart
ID: 12247046
Have you given the key properly

what could i check here?
0
 

Author Comment

by:hreinart
ID: 12247132
maybe i send you the database?
0
 
LVL 14

Expert Comment

by:p_partha
ID: 12247837
ok, my id is in my profile..
0
 

Author Comment

by:hreinart
ID: 12248373
it's on the way,  thanks.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 14

Expert Comment

by:p_partha
ID: 12248697
Just add this line to your agent

      Dim session As New notessession

Partha
0
 

Author Comment

by:hreinart
ID: 12248977
hi,

thanks for this information.
i'm out of the office now.
i'll return later and let you know via ee



thanks
harald
0
 

Author Comment

by:hreinart
ID: 12251388
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?
0
 

Author Comment

by:hreinart
ID: 12251489
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?
0
 

Author Comment

by:hreinart
ID: 12256496
hi,

i tested the database now on a domino server.
same result.

i have no idea why the agent doesn't work.
0
 
LVL 14

Accepted Solution

by:
p_partha earned 180 total points
ID: 12259254
     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)
      Print "This is the key given by me " & key
      Set doc = view.GetDocumentByKey (key)
      If Not (doc Is Nothing) Then
            Print "Hurray document found , i am coming inside"
            Call dateTime.SetNow
            Set doc.rueckgabe = dateTime
            Print "the field rueckgabe is being set to today"
            Call doc.Save(True,True)
            Print "doc is saved"  ' if this is not printed, then probably you don't have access to save the document
            
      End If
      Set db = session.CurrentDatabase
      Set view = db.GetView ("($NR)" )
      key2 = curdoc.buchnummer(0)
      Set doc = view.GetDocumentByKey (key2)
      Print "This is the second key given by me " & key2
      If Not (doc Is Nothing) Then
            Print "Hurray document found , i am coming inside"
            Set Item = doc.ReplaceItemValue("status","vorhanden")
            Call doc.Save(True,True)
            Print "doc is saved"
      End If


Paste this agent as it is and tell me what are the things that are printed when you click on the button in your form

Partha
0
 

Author Comment

by:hreinart
ID: 12267514
hi i was out for a day.
try to test it this evening or tomorrow.


thanks sofar for your work. !!!
0
 

Author Comment

by:hreinart
ID: 12268132
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
0
 

Author Comment

by:hreinart
ID: 12268172
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?
0
 

Author Comment

by:hreinart
ID: 12268257
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



0
 

Author Comment

by:hreinart
ID: 12268359
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

0
 

Author Comment

by:hreinart
ID: 12278396
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
0
 
LVL 14

Expert Comment

by:p_partha
ID: 12280080
Thx for the points and check this out for the date difference



replace yourdatefield with the fieldname
(@Today - @Date(<your date field>))/86400

Parta
0
 

Author Comment

by:hreinart
ID: 12285413
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.....
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now