Scheduled agent imported via DXL will not "trigger"

Hi

Scenario:

======

I need to hide the design of a database template which is to be installed in

different organisations. The application contains a scheduled agent that I need

to control. I need to set on which server it runs, at what interval, and on

behalf of whom it runs (typically the server since it accesses other servers

and we need to set up trust between them). The agent has to be set to "Allow

restricted operations" since I run some Java code using external JAR-files to

call a webservice

I have created a new copy of the template with hidden design. This effectively

hides all designelements. However, I can create a new agent directly in this

database - but only as a private agent! So I cannot use this as a solution.

From LotusScript I can set the server to run the agent on and I can

disable/enable the agent. But I cannot set the schedule nor whom to run the

agent on behalf of.

DXL:

===

So I tried use DXL. For simplicity the steps below have all been carried out on

a database where the design has not been hidden. I have exported the agent and

tried to modify the data I need to adjust and reimport the agent. First

observations are:

  1. I cannot import an agent that use simple actions

  2. I cannot import an agent that use Formula language

In both cases I get the message: "This action cannot be recognized by this

version of Lotus Notes"…

However, I found out through an example here in the forum (http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/

7f97d5c3b3d1a763852570890054833f?OpenDocument)

that I can import a LotusScript agent. And that all seems fine when I look at

the code, properties, etc.

But it does not trigger!!

If I manually recreate the agent with exactly the same settings it will run Ok.

Procedure to reproduce:

================

Create an agent that you want to export/import. I called mine “Event Listener”

and used the following code:

Dim s As New NotesSession

Dim agt As NotesAgent

Set agt = s.currentDatabase.getAgent("(wsListener)")

If Not agt Is Nothing Then

	Call agt.run()

End If

Set the agent to be scheduled e.g. every 10 minutes and set the agent to run on

behalf of your server and to allow restricted actions. Save the agent, check

that it runs as scheduled, and disable it.

Now open the agent again and select Tools\DXL Utilities\Exporter… in the

menus and point to a text file. In this example I used d:\temp\NewAgent1.dxl. I

selected format “DXL file” but I haven’t really noticed any difference between

that and “XML file” format.

Now create a new agent to import the other agent. I used this code:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim filename As String

Set db = session.CurrentDatabase

filename$ = "d:\temp\NewAgent1.dxl"



REM Open dxl file 

Dim stream As NotesStream

Set stream = session.CreateStream

If Not stream.Open(filename$) Then

	Messagebox "Cannot open " & filename$,, "Error"

	Exit Sub

End If

If stream.Bytes = 0 Then

	Messagebox "File did not exist or was empty",, filename$

	Exit Sub

End If



REM Import DXL into new database

Dim importer As NotesDXLImporter

Set importer = session.CreateDXLImporter(stream, db)

importer.ReplicaRequiredForReplaceOrUpdate = False

importer.DesignImportOption = DXLIMPORTOPTION_REPLACE_ELSE_CREATE

Call importer.Process



' Sign the imported agent...

Dim nc As NotesNoteCollection

Dim noteId As String

Dim doc As NotesDocument

Set nc = db.CreateNoteCollection(False)

nc.SelectAgents = True

nc.SelectionFormula = "@LowerCase($Title)=""event listener"""

Call nc.BuildCollection

If nc.Count > 0 Then

	noteId = nc.GetFirstNoteId()

	Set doc = db.GetDocumentByID(noteId)

	Call doc.Sign()

	Call doc.save(True,False)

End If

Please note that you need to know the name of the agent to sign it as part of

importing it.

Now remove the first agent (“Event Listener” in my example) from your database

and run the second agent to reimport the scheduled agent. Enable the newly

imported agent from the agent list and wait… It does not trigger - at least

not on my server. You can open the agent and check all the settings. They seem

to be correct.

Subsequently, I have tried to change the agents LotusScript code and save the

agent. It still does not trigger!

Any advice as to where I am going wrong would be greatly appreciated! This is a

really nice feature if we can make it work.

Regards

John

PS. Sorry for the long description, but I thought I would show the code for you

to try yourself :wink:

Subject: Agent imported via DXL… Notes 6.5 vs. 7 matters!

I have done some further testing.

It seems that what I want to do actually works if I use a Notes 6.5.4 to eksport and import the agent! And it makes no difference if the server is a Domino 6.5.4 or 7.0.

And the other way round it never works - i.e. when I use a Notes 7.0 to import the DXL (no matter if the DXL was created using a Notes 6.5.4 or 7.0). And it makes no difference what server version I use.

I have also tried to remove the “Run on behalf of” and change the security setting to most secure (ie. not allow restricted operations). Those changes seem to make no difference either.

Unfortunately, it is not really an option to use a Notes 6.5.4 to enable the agent since the application requires Notes and Domino 7 for everything else… :frowning:

So any good advice is still very much appreciated.

Regards

John

Subject: RE: Agent imported via DXL… Notes 6.5 vs. 7 matters!

I made some testing those days on importing agents using DXL.

The agents you import are not signed !!

That’s probably why your schedule agents do not run.

So what you have to do is take the agent UNID out of the xml stream of the agent you import.

You can get the unid in the xml node .

Then if we suppose the unid is stored in the variable agUNID do the following :

dim agentdoc as NotesDocument

setAgentdoc=session.CurrentDatabase.GetDocumentByUNID(agUNID)

if not agentdoc is nothing then

call agentDoc.sign()

call agentdoc.save(true,false)

else

print “Agent not found”

end if

Hope this helps

Renaud Thievent

Subject: Scheduled agent imported via DXL will not “trigger”

Hello John,

do you get any other answer to your question? We have exactly the same problem currently.

Thanks,

Christiane

Subject: Scheduled agent imported via DXL will not “trigger”

I realize it’s been a long time since the original post, but I was wondering if anyone has found any resolution for this problem. I am experiencing the exact same issue and am at the end of my rope…

Thanks for any advice.

Amy

Subject: RE: Scheduled agent imported via DXL will not “trigger”

Amy.

Did you try to sign the agent as I suggested in my previous post ?

Before doing it using lotusscript, try to sign it using the designer and look in the agent manager (“tell amgr sched” on the server console) to see if it’s in the schedule.

It might take about 1 minute to see it in the agent manager since you signed it.

Renaud

Subject: Scheduled agent imported via DXL will not “trigger”

Hi John,just a quick idea:

have you stripped from the agent DXL (using XSLT) anything that points to it’s origination? Like ReplicaID, ServerName etc? That could stop the trigger.

Hth

:slight_smile: stw

Subject: RE: Scheduled agent imported via DXL will not “trigger”

Hi Stephan

Thank you for your reply.

Well, I have given exactly that issue some thought. The example that I gave reimported the agent into the exact same database that it was exported from - to prevent issues with replica id, server name, etc. to influence the situation.

In the “real” situation I am trying to use a DXL file like:

<?xml version='1.0' encoding='utf-8'?>

<agent name=‘Event Listener’ xmlns=‘http://www.lotus.com/dxl’ version=‘7.0’

maintenanceversion=‘2.0’ hide=‘v3 Notes’ publicaccess=‘false’ designerversion=‘7’

runonbehalfof=‘<<>>’ restrictions=‘unrestricted’ activatable=‘false’

enabled=‘false’>

Option Public

Option Declare

Sub Initialize

Dim s As New NotesSession

Dim agt as NotesAgent

set agt = s.currentDatabase.getAgent(“(wsListener)”)

if not agt is nothing then

call agt.run()

End if

End Sub

You will notice some “tags” that I will substitute with real values before importing the agent.

If you compare the above with what is exported by Notes you can see that a lot of the informative tags have been removed. This is an example of what Notes exports:

<?xml version='1.0' encoding='utf-8'?>

<agent name=‘Event Listener’ xmlns=‘http://www.lotus.com/dxl’ version=‘7.0’

replicaid=‘C12570FA0079B963’ hide=‘v3’ noreplace=‘true’ publicaccess=‘false’

designerversion=‘7’ runonbehalfof=‘CN=Srv2R6/O=D-D’ restrictions=‘unrestricted’

activatable=‘false’ enabled=‘false’>

20060119T104730,59+01

20060119T105204,34+01

20060119T105204,33+01

20060119T105204,33+01

20060119T104915,74+01

CN=John Dalsgaard/O=D-D

CN=John Dalsgaard/O=D-D

20060119T104907,46+01

Option Public

Option Declare

Sub Initialize

Dim s As New NotesSession

Dim agt As NotesAgent

Set agt = s.currentDatabase.getAgent("(wsListener)")

If Not agt Is Nothing Then

	Call agt.run()

End If

End Sub

20060119T105156,07+01

In my tests it seems to make no difference if I remove the tags or not (provided that I use some of the flags to control importing design elements, eg. ignoring replica information).

Regards

John