?
Solved

Lotus Script Agent Fails

Posted on 2006-04-03
22
Medium Priority
?
496 Views
Last Modified: 2013-12-18
I am running the following code from an agent (web client) and am getting PAGE NOT FOUND error:

Option Public

Dim db As NotesDatabase
Dim maildoc As NotesDocument
Dim subject As String
Dim linkmsg As String
Dim newexist As String
Dim projinfo As String
Dim recipients As Variant

Sub Initialize
      Set db = s.CurrentDatabase
      Set maildoc = db.CreateDocument
      Set bodyitem = maildoc.CreateRichTextItem("Body")
      maildoc.Form = "Memo"
      If Source.IsNewDoc Then
            newexist = "New Project - "
      Else
            newexist = "Project Info Modified - "
      End If
      projinfo = doc.GetItemValue("ProjName")
      recipients = "Michael Rothschild"
      subject = newexist & projinfo
      maildoc.Subject = Subject
      Call bodyitem.AppendDocLink(linkdoc)
      maildoc.SendTo = recipients
      Call maildoc.Send(False)
End Sub
0
Comment
Question by:paynestreet
  • 10
  • 8
  • 4
22 Comments
 
LVL 14

Expert Comment

by:p_partha
ID: 16364022
it may not be due to agent alone may be it's b ecoz of the $$return.

I hope this is a webquerysave agent, just try this in the agent

Sub Initialize
on error goto par
     Set db = s.CurrentDatabase
     Set maildoc = db.CreateDocument
     Set bodyitem = maildoc.CreateRichTextItem("Body")
     maildoc.Form = "Memo"
     If Source.IsNewDoc Then
          newexist = "New Project - "
     Else
          newexist = "Project Info Modified - "
     End If
     projinfo = doc.GetItemValue("ProjName")
     recipients = "Michael Rothschild"
     subject = newexist & projinfo
     maildoc.Subject = Subject
     Call bodyitem.AppendDocLink(linkdoc)
     maildoc.SendTo = recipients
     Call maildoc.Send(False)
exit sub
par:
Print "Error Occured on line number" & erl & " Error is " & error
exit sub
End Sub
0
 

Author Comment

by:paynestreet
ID: 16365210
The results are the same.
It seems as though you took out the Dims and aded an exit sub.
i do have a value in $$Return. Should I remove it?
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16365236
Try instantiating the s object

Dim s as new NotesSession
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:p_partha
ID: 16365285
as marilyng said Session shd be declared, if you had not declared, my error routine wud have told you exactly wehre the error is, so i presume that is declared. Try removing the $$return and see whether it works.

Partha
0
 

Author Comment

by:paynestreet
ID: 16365306
maryling,

Same result.
Is there any way to debug an agent?
Does this code have to run in an agent?
0
 

Author Comment

by:paynestreet
ID: 16365344
Partha.

Removing the $$Return didn't help.
I really don't know how far I'm getting- or if I'm even getting to the agent.
0
 
LVL 14

Expert Comment

by:p_partha
ID: 16365353
Go to your internet explorer, Go to tools --> internet options , go to the advanced tab(last tab), uncheck show friendly http error messages and then refresh the page which is throwing page cannot be found error

Partha
0
 

Author Comment

by:paynestreet
ID: 16365388
I got:

Error 404
HTTP Web Server: Lotus Notes Exception - Entry not found in index
0
 
LVL 14

Expert Comment

by:p_partha
ID: 16365420
Most probably there is a dblookup that is failing in the page use @iserrro
or
Sometimes it's possible that you find this kind of error when you use a webquerysave agent and within it you use some wrong field name or view name. So, the solution, in this case, is to try to remove the agent to the webquerysave event and verify that the form has been proceeded. If it so, the problem is in your Lotus agent.

CHeck whether your agent is spelled correctly.
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16365459
Call bodyitem.AppendDocLink(linkdoc)  < where is linkdoc defined?

As far as debugging agent, you can either put print statements that will appear in the log.nsf, or run agentlog to send you an email of everything, and log action everywhere.

Also, set Option Declare in the options to make sure you have everything declared.

Entry not found in index.. linkdoc can't be found, I think, or you have some link defined where it cannot be found in the default view index.


0
 

Author Comment

by:paynestreet
ID: 16365490
Are you saying just to put the code in the WebQuerySave event?
I thought I had to use an agent.
0
 

Author Comment

by:paynestreet
ID: 16365610
partha,

You were correct. I had forgotten to remove the <> from around the agent name, so that's why I wasn't executing.

Maryling,

I just want to point to the doc that is being saved. WHat is the correct reference?

doc or _doc ?
0
 

Author Comment

by:paynestreet
ID: 16365697
Now htat I'm getting to the code, Partha's error routine is showing me:

"Error Occured on line number15 Error is Variant does not contain an object"

Here is my code:

Sub Initialize
      On Error Goto par
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Dim maildoc As NotesDocument
      Dim subject As String
      Dim linkmsg As String
      Dim newexist As String
      Dim projinfo As String
      Dim recipients As String
      Set db = s.CurrentDatabase
      Set maildoc = db.CreateDocument
      Set bodyitem = maildoc.CreateRichTextItem("Body")
      maildoc.Form = "Memo"
      If Source.IsNewDoc Then
            newexist = "New Project - "
      Else
            newexist = "Project Info Modified - "
      End If
      projinfo = doc.GetItemValue("ProjName")
      recipients = "Michael Rothschild"
      subject = newexist & projinfo
      maildoc.Subject = Subject
REM Call bodyitem.AppendDocLink(linkdoc)
      maildoc.SendTo = recipients
      Call maildoc.Send(False)
                Exit Sub
           par:
      Print "Error Occured on line number" & Erl & " Error is " & Error
      Exit Sub
End Sub
0
 
LVL 14

Expert Comment

by:p_partha
ID: 16365718
Source is not defined...

try like this

Set source = s.documentcontext on top of this if condition:
If Source.IsNewDoc Then
0
 

Author Comment

by:paynestreet
ID: 16382067
I'm now getting type mismatch.
.
.
Dim s As New NotesSession
Dim db As NotesDatabase
Dim source As NotesDocument
.
.
.
Set db = s.CurrentDatabase
Set source = s.DocumentContext
If source.IsNewDoc Then
newexist = "New Project - "
Else
newexist = "Project Info Modified - "
End If
0
 
LVL 14

Expert Comment

by:p_partha
ID: 16382090
Please tell us  which line you are getting the error..

Partha
0
 

Author Comment

by:paynestreet
ID: 16382669
If source.IsNewDoc Then
0
 
LVL 14

Accepted Solution

by:
p_partha earned 2000 total points
ID: 16382988
try
if source.isnewnote then

Partha
0
 

Author Comment

by:paynestreet
ID: 16383639
IsNewNote worked!
What is the rule?
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16387993
isnewnote is a property of NotesUIdocument, isnewdoc is property of NotesDocument

Glad you got it to work... sorry, been on a project so time is limited to night, these days.  Glad p_Partha was around to assist.
0
 
LVL 14

Expert Comment

by:p_partha
ID: 16388158
Marilyng
I believe isnewnote is for notesdocument, not for notesuidocument...

Partha
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16388250
Yup, got it backwards.. that's what the F1 button is for!! :)  Never trust my memory anymore... #$%#$% growing old(er)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

807 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