Lotus Script Agent. No error but doesn't work

Hi All,

I attached a small Lotus sript that should save detachments from mails.
The script shows no error messages but it doesn't work unfortunately.

Could you please tell me what's wrong with it?
Thanks,

Agent.txt
verto33Asked:
Who is Participating?
 
CRAKConnect With a Mentor Commented:
So all you really need is the unprocessed document collection?

Sub Initialize
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim coll As NotesDocumentCollection
	Dim doc As NotesDocument
	Dim body As NotesRichTextItem
	Dim rtitem As Variant
	
	Dim directory As String
	Dim attachname As String
	Dim filename As String
	Dim oname As String
	
	directory="D:\Detach\"
	
	Set db = session.CurrentDatabase
	Set coll = db.UnprocessedDocuments
	
	Set doc=coll.GetFirstDocument
	Do While Not doc Is Nothing
		
		Set rtitem = doc.GetFirstItem( "Body" )
		Forall o In rtitem.EmbeddedObjects
			oname=directory + o.name	
			Call o.ExtractFile( oname )	
		End Forall
		
		Set doc = coll.GetNextDocument(doc)  
	Loop
End Sub

Open in new window

0
 
fgrushevskyCommented:
What does it say in the agent log? check ECL, could it be that agent signer does not have rights to access filesystem?
0
 
CRAKCommented:
You may need to set the agents privileges (2nd tab, half way) to "2. Allow restricted operations". That will allow reading/writing files to disk.

If it runs scheduled, you'd need privileges for that as well (domino directory, server document, restrictions tab).
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
verto33Author Commented:
The "Set runtime security level" is set to 2
I even tried it with the 3 but no error message and no result.
The laptop user has full access to the D:\Detach folder

It isn't scheduled but Action menu selected.
Do you have any idea what the problem could be?

Where can I find the agent log?
0
 
fgrushevskyCommented:
Open database in Designer,  within Designer go to agents , (Shared Code - Agents), highlight your agent, then go to the  "agent" menu and select log there
0
 
CRAKCommented:
Assuming disk access is ok then (i.e. you can write files to D:\Detach yourself as well) and given the fact that you see no errors, my guess would be that the unprocessed search raises a 0-document collection.

Switch the Lotusscript debugger on to see what happens. The Do while-loop may never execute.
Or add a messagebox to display shipping.count before you trigger that loop.
0
 
FormanJackJCommented:
I would add PRINT statements to your code so you can see if it is running and the progress of the agent. If you run this agent at the server. the print will show in the server's console & log database.

I looked your agent, and I added PRINT statements to it.
Agent-Rev2.txt
0
 
verto33Author Commented:
fgrushevsky:
I attached the agent.log

FormanJackJ:
I attached the code to make ou see that one of the printing line gives an error.
I removed this line but then still no error and no saving.
No screen message appeared

CRAK:
I switched on the lotus debugger but it shows no error

Just to be sure I made everything well.
If I open the Agent in the designer I see following:
Document Selection   --empty
(Options)      -empty
(Declarations)      -empty
Initialize       here is the whole code
Terminate      -empty

print-code.doc
agent-log.doc
0
 
CRAKCommented:
0.name in that line should be o.name
(ie letter "o" next to p instead of number 0)
0
 
CRAKCommented:
Debugging shows no error, but doet it enter the while loop, or does it jump from "while" straight to wend on its 1st attempt?

That may happen when no docs meet the search criteria.
0
 
verto33Author Commented:
The debugger jump from the line
Do While Not shippingDoc Is Nothing

directly to the line
End Sub

If e.g. 2 mails are selected with attachments
0
 
CRAKCommented:
Ok, that what I expected!
That means that the agent did not get any documents... documentcollection is empty (.count=0)

At this time the collection is based on this line:
Set shipping=db.unprocessedSearch({@Contains(@upperCase(Subject);"SHIPPING")},Nothing,0)

The documents returned (according to designer help) are collected must...:
- be considered "unprocessed" by the current agent
- meet the specified search criteria
- were created or modified since the cutoff date

"Unprocessed" depends on what the agent is set to run on (selected docs, all docs in a view etc). You may want to consult designer help for all details.
The cutoff date is set to Nothing in your code, so we can rule that limitation one out already!

That leaves two things for you to look into:
1) What does the agent run on?
2) Do (some of) the selected documents meet the search criterium (i.e. does the Subject field contain "Shipping" (in any case type).

Do let us know (if you don't know how to check, don't be shy!)
0
 
verto33Author Commented:
Sorry, it was my fault. I didn't realize that the subject doesn't contain the word "Shipping"

I got this code from a colleague and I didn't check the conditions.

Is there a way to remove this condition with the subject? I tried but got errors every time.
Something like replacing shippingDoc with AllDoc or SelectedDoc?
0
 
verto33Author Commented:
Thanks for your help. It works perfect.
0
All Courses

From novice to tech pro — start learning today.