Webquerysave agent does not work

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.
LVL 2
kaliosAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Sjef BosmanConnect With a Mentor Groupware ConsultantCommented:
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
 
RanjeetRainCommented:
Try

Call doc2.save(True, False)  
   
0
 
kaliosAuthor Commented:
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
RanjeetRainConnect With a Mentor Commented:
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
 
HemanthaKumarConnect With a Mentor Commented:
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
 
kaliosAuthor Commented:
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
 
HemanthaKumarCommented:
log file is on your server which runs your http service
0
 
Sjef BosmanGroupware ConsultantCommented:
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
 
RanjeetRainCommented:
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
 
kaliosAuthor Commented:
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
 
Sjef BosmanGroupware ConsultantCommented:
Better use MsgBox, the output will be placed in the log database, under miscellaneous.
0
 
kaliosAuthor Commented:
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
 
kaliosAuthor Commented:
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
 
kaliosAuthor Commented:
are there any properties I need to check in the database or the config form?
0
 
qwaleteeConnect With a Mentor Commented:
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
 
Sjef BosmanGroupware ConsultantCommented:
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
 
kaliosAuthor Commented:
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
 
kaliosAuthor Commented:
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
 
kaliosAuthor Commented:
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
 
kaliosAuthor Commented:
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
 
Sjef BosmanConnect With a Mentor Groupware ConsultantCommented:
"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
 
HemanthaKumarConnect With a Mentor Commented:
15K is the limit for the text fields
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.