Solved

Webquerysave agent does not work

Posted on 2004-08-04
22
843 Views
Last Modified: 2013-12-18
Hi Experts,

I'll be as much detail as I can. I have two forms.. one is visible only in web. one is visible only in notes. both have same names and same fields.
So if i compose a new document and save it over the web it also stores the values in the notes form.  Now I've a button in the notes form which when clicked will save the notes form and runs an agent.  This agent runs fine when the the button is clicked in notes.
However, if use the same agent in the webquery save agent for the web form it does not work. What could be wrong with this?

Here is the agent.

Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim view As NotesView
      Dim doc As NotesDocument
      Dim doc2 As NotesDocument
      Dim doc3 As NotesDocument
      Dim Line1 As String
      Dim Line2 As String
      Dim Line3 As String
      Dim ritem As NotesRichTextItem
      
      Set db = session.CurrentDatabase
      Set doc = session.DocumentContext
      Set view = db.GetView("PortalAD")
      Let AddMANCount = 0
      
      Set doc3 = New NotesDocument(db)
      doc3.form = "Memo"
      
      doc3.SendTo = BMmail      
      doc3.CopyTo = EDImail
      
      doc3.Subject = "Portal Adds & Deletes Request # " & doc.txtFormNumber(0) & " has been Processed successfully."
      
      Line1 = "Portal Adds & Deletes Request # " & doc.txtFormNumber(0) & " submitted by " & doc.Origname(0) & " for CustomerID-ConfigID " & doc.CusconID(0) & " has been successfully processed " & Chr$(10) & Chr$(10)       
      Line2= "You are receiving this email because you are the Originator of this request. "  & Chr$(10)
      Line3= "If you are NOT the originator, please report to xxx@xxx.com " & Chr$(10) & Chr$(10)
      Set rtitem = New notesRichTextItem(doc3,"Body")
      Call rtitem.appendText(Line1 & Line2 & Line3)
      Call doc3.send ( True )      
      
      Let SearchFormula$ = "Form = ""Config"" & " _
      & "@Text(Password) = """ & doc.CusconID(0) & """ & " _
      & "ConfigStatus = """ & "L" & """ & " _
      & "@Isresponsedoc= 0  & "_
      & "Version != """ & "2.0" & """ "                           
      
      Set Collection = db.search( SearchFormula$, Nothing, 0 )
      'Print "Searchformula : '" & SearchFormula$ & "'"
      
      If Collection.Count = 0 Then
            Goto SkipRecord            
      Else
            Set doc2 = Collection.GetFirstDocument      
            If doc.Typeofaction(0) = "A" Then
                  Goto AddMANs
            End If
            
            If doc.Typeofaction(0) = "D" Then
                  Goto DeleteMANs
            End If
            
            Goto SkipRecord
      End If
      
AddMANs:           
      Dim item1 As NotesItem
      Set item1 = doc2.GetFirstItem("MTN")                              
      
      Forall m In doc.MAN
            Call item1.AppendToTextList(m)                                        
            Let AddMANCount = AddMANCount + 1
      End Forall
      
      Dim result1 As Variant              
      
      result1 = Evaluate(|@Unique(MTN)| , doc2)
      doc2.MTN = result1            
      
      Call doc2.ComputeWithForm(True,True)      
      Call doc2.save(False,True)                
      Goto SkipRecord
      
      
DeleteMANs:
      Goto SkipRecord
      
      
SkipRecord:           
      'Print exiting program -- commented
      
End Sub

When I use this agent in the webquery save agent, it is sending the email successfully. I've also given a print statement after the Forall statement.
It displayed the print statement in the browser. If I remove the print statement and run it it says form processed over the web. But it is not appending values to the doc2.MTN field.
0
Comment
Question by:kalios
  • 10
  • 5
  • 3
  • +2
22 Comments
 
LVL 19

Expert Comment

by:RanjeetRain
Comment Utility
Try

Call doc2.save(True, False)  
   
0
 
LVL 2

Author Comment

by:kalios
Comment Utility
I tried all these.. but nothing works.

Call doc2.save(True,True)
and
Call doc2.save(True,False)
and
Call doc2.save(False,True)


thanks
0
 
LVL 19

Assisted Solution

by:RanjeetRain
RanjeetRain earned 50 total points
Comment Utility
Try this:

    Dim item1 As NotesItem
    Set item1 = doc2.GetFirstItem("MTN")                        
     
    Forall m In doc.MAN
         Call item1.AppendToTextList(m)                                  
          Let AddMANCount = AddMANCount + 1
    End Forall
    Call doc2.ReplaceItemValue ("MTN", Item1.Values)
    Call doc2.save(False, True)              
   
    Dim result1 As Variant              
     
    result1 = Evaluate(|@Unique(MTN)| , doc2)
    doc2.MTN = result1          
   
     Call doc2.ComputeWithForm(True,True)    
     Call doc2.save(False,True)              
   
0
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 150 total points
Comment Utility
Is this MTN Field. .. COmputed field ?? If so enable generate html for all fields in the form property.


Secondly, check your log.nsf after saving the document over web... for any error or warning msgs . That is your best bet

~Hemanth
0
 
LVL 2

Author Comment

by:kalios
Comment Utility
MTN field is not computed. Its an Editable field (Allow multiple values is checked for this field). Also I've checked enable generate html for all fields in the form property. Still dosen't work..

Where do I find the log.nsf file.

Also Ranjeet, I tried your code above. Same Result.

thanks
Kalios
0
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
log file is on your server which runs your http service
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Try ComputeWithForm(True,False). If an arror occurs in an agent, it just stops... Be sure that ComputeWithForm doesn't generate the error, so you can exclude that.
0
 
LVL 19

Expert Comment

by:RanjeetRain
Comment Utility
Try commening out these lines:

   Dim result1 As Variant                    
   result1 = Evaluate(|@Unique(MTN)| , doc2)
   doc2.MTN = result1          
   
    Does it save the document in this case?
0
 
LVL 2

Author Comment

by:kalios
Comment Utility
OK, I only have this now and still it does not work

                Dim item1 As NotesItem
      Set item1 = doc2.GetFirstItem("MTN")                              
      'Print "values in doc.MAN are ==> " doc.MAN
      Forall m In doc.MAN
            Call item1.AppendToTextList(m)                                        
            Let AddMANCount = AddMANCount + 1
                                'Print "AddMANCount is " AddMANCount
      End Forall
      
      Call doc2.save(True,False)    
      
      Goto SkipRecord

If you see above there are 2 print statements which are commented now. It is not showing the first print statement in the browser and instead it is showing the second Print statement. It is giving me the AddMANCount. Also If I put Print doc2.MTN it does not show anything.


      
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Better use MsgBox, the output will be placed in the log database, under miscellaneous.
0
 
LVL 2

Author Comment

by:kalios
Comment Utility
I do not have access to the domino server to look at the log file. Its maintained by our Notes Support group and they never respond on time and its a big process to get permission from them to view the log file. Is there something i can do here. this is really crazy. the same agent works fine if I run it in notes client. but does not in the web. it is not able to update or save the document i guess.
I doubt if its reading the doc2.MTN field.........

If I put Print doc2.MTN it does not show anything.. same with doc.MAN.

However, if I put Print doc2.MTN(0) and Print doc.MAN(0) it shows the value...

By the way is this related to time constraint. Would it make a difference If I change the way i search the db.
Too many questions.

thanks
Kalios

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 200 total points
Comment Utility
Some silly questions:
- do you have permission to run agents on the server? [YES]
- if you write a simple agent that does anything stupid (e.g. just a print), does that work? [YES]
- in 99% of the servers, the log.nsf is open for internal users; I thought I was paranoid, but this...

Access to log.nsf is almost mandatory, if you cannot get that you're almost lost in the labyrith of possible errors.
0
 
LVL 2

Author Comment

by:kalios
Comment Utility
Sjef,

The answers to your question 1 and 2 is yes.

Will there be categories in the type of permissions for running agents on the server.

If you see the above agent, it also has an email piece. It is sending email successfully when run on the web which means that I do have access to run the agents on the server. Only it is not able to updated the document that it got in the search. I'll try see the log.nsf file meanwhile.
Also, I tried to update another field with just this piece of code and it did not work either.

Its not updating the document. Does this mean that agents running on the server do not have update access in this case..

     Let doc2.ConfigStatus = "C"    
     Call doc2.save(True,False)    
     
     Goto SkipRecord






0
 
LVL 2

Author Comment

by:kalios
Comment Utility
are there any properties I need to check in the database or the config form?
0
 
LVL 31

Assisted Solution

by:qwaletee
qwaletee earned 100 total points
Comment Utility
FIrst, learn ow to use the NotesLog facility.  If you don't have access to the server log or to file on the server, then you will have o eithe ruse an e-Mail log or the agent's own log.   The latter is "safer" in that you always have access, and it normally will record stuff even if the agent crashes with the log still open, while messages sometimes do not.

Log EVERYTHING, e.g., "Got doucment, note ID is x UNID is Y, key field values are a=b, c=d" ... "Creating mail message" ... "Setting mail subject to z" ... etc.

You also REALLY ought to put in error checking.

Finally, for webQuerySave, all output is sent to the browser, so you coudl put in lot sof print statements instead of using NotesLog, and you would see the result in the browser.  Just remember to put in <BR> at the end of each print statement.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Using NotesLog objects is a lot more work, but will pay off in the long run. The logging to mail used to crash Notes in 5.0.?, and logging to the agent used to be restricted to 64K bytes or so. If y ou create a standard set of functions (or an object), you can always use these functions when you're debugging agents. For a quick problem resolution, I prefer log.nsf.
0
 
LVL 2

Author Comment

by:kalios
Comment Utility
ok,

All I have is this now:

                Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim view As NotesView
      Dim doc As NotesDocument
      Dim doc2 As NotesDocument

      Set db = session.CurrentDatabase
      Set doc = session.DocumentContext
      Set view = db.GetView("PortalAD")
      
      Let SearchFormula$ = "Form = ""Config"" & " _
      & "@Text(Password) = """ & doc.CusconID(0) & """ & " _
      & "ConfigStatus = """ & "L" & """ & " _
      & "@Isresponsedoc= 0  & "_
      & "Version != """ & "2.0" & """ "                           
      
      Set Collection = db.search( SearchFormula$, Nothing, 0 )
      
      If Collection.Count = 0 Then
            Goto SkipRecord            
      Else
            Set doc2 = Collection.GetFirstDocument      
            If doc.Typeofaction(0) = "A" Then
                  Let doc2.Configstatus = "C"      
                  Call doc2.save(True,False)                  
                  Goto SkipRecord
            End If
            
            If doc.Typeofaction(0) = "D" Then
                  Goto SkipRecord
            End If            
            
      End If

SkipRecord:
'Print exiting program

The same code works fine in Notes Client and does not in the web.
Do you see anything abnormal with the code above. Also I'm in a process of getting the log.nsf file.
I've put prints all over everything shows perfect, expect the save is not working i guess.

Something is bothering Call doc2.save(True,False)      

Does the database needs special access for agents to update documents.
By the way the Agents own log does not say anothing except the start time and end time.

thanks
Kalios
0
 
LVL 2

Author Comment

by:kalios
Comment Utility
By the way in the Agent Properties I've TARGET = None.

Is this all right.. Should I have "All documents in the Database".

thanks
Kalios
0
 
LVL 2

Author Comment

by:kalios
Comment Utility
All right... I found the problem..

I've given 'Run on behalf of' a special name for the agent. However, That name is not in the ACL. I added the name in the ACL with Editor Access
and it works like a charm.

Thanks again for everyones input on this.

Kalios
0
 
LVL 2

Author Comment

by:kalios
Comment Utility
One last question..

In the web form the field doc.MAN is a multi-value field and can have any number of values. When the web query agent runs it appends all the values from doc.MAN to doc3.MTN field (also a multi-value field) in the config form. Is there a limit in sending the number of values from doc.MAN to doc3.MTN.

Please advise
thanks
Kalios
0
 
LVL 46

Assisted Solution

by:Sjef Bosman
Sjef Bosman earned 200 total points
Comment Utility
"On behalf of"... That's one thing I forgot to ask in my silly questions above :-$ Goof you found that!

There are some limits on the number of values in a multi-value item, see the Designer Help, and look under Limits in the Index. There is an array limit (-32768 to 32767), but if that also applies to multi-value fields, I don't know.
0
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 150 total points
Comment Utility
15K is the limit for the text fields
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

728 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

14 Experts available now in Live!

Get 1:1 Help Now