Agent.save on manual agent does not change owner

The following manual agent successfully saves and re-signs the manual ‘testing’ agent in R5.

In R6, I don’t get an error, but the agent.save does nothing.

Dim s As New NotesSession

Dim db As NotesDatabase

Set db = s.CurrentDatabase

Dim agent As NotesAgent

Set agent = db.GetAgent(“testing”)

Call agent.save()

I understand the new ‘Sign agents to run on behalf of someone else’ feature, but thought that only applied to agents running on the server.

Subject: agent.save on manual agent does not change owner

Try changing something unimportant about the agent programatically, such as enable/disable status and then save. It maybe that it tries to be too smart and does not save because nothing changed.

Subject: RE: agent.save on manual agent does not change owner

Thanks Julie. Changing IsEnabled and then calling agent.save worked (but only when running the script on a scheduled agent)

The agent I want to update is run from the actions menu and I don’t see any read/write script options for a manual agent. Any ideas?

Subject: RE: agent.save on manual agent does not change owner

Did you ever figure this out, I’m tring to remove the (editofficeprofile) agent to recreate and I’m seeing the same issue. Can’t remove an agent that dosen’t belong to me and ag.save() isn’t signing the agent.

Subject: RE: agent.save on manual agent does not change owner

You have to set a property of the agent, like agent.Server, and then save it. But you also need a new NotesSession to recognize the new signer, so you have to call another agent to do the actual remove.

Subject: agent.save on manual agent does not change owner

Do you have ‘allow user activiation’ turned on? This is meant for editor level users and saving such agent would does not resign the agent.

Subject: RE: agent.save on manual agent does not change owner

Thanks for your response. That option is not available for agents that run from the Actions menu.

Subject: agent.save on manual agent does not change owner

How do you know the signiture is not being changed? Are you looking at the signiture value in the properties box or are you looking at the Designer display? The Designer does not show you the signer, it shows you the value of the person who last updated the document. There is a tip about this in the Agent FAQ that bailed me out once.

Subject: RE: agent.save on manual agent does not change owner

I am looking at the Designer display. Although the Seq Num of $Signature field is not updating, so I don’t think it’s saving.

I should also say that I really want to change the owner/signer of the agent so I can then delete it.

Subject: RE: agent.save on manual agent does not change owner

The two read/write properties are Server name and enable/disable status. I assumed you tried both an both fail because it is a menu agent? I wrote the developer about this situation, but in the short term maybe there is another way to get this done.

There is a new method that signs elements in the database, that will do what you want in a slightly different way.

Why do you need to change signiture to delete it? Are you trying to use AdminP to do the deletions? You could delete the agent programatically yourself if you have proper access.

Subject: RE: agent.save on manual agent does not change owner

Julie

Thanks again for following this thread. I have been away and I am now looking into it again. I was able to change the agent’s signer using the agent.Server value, even though it does not apply to menu-driven agents. This is good news.

Now that I have signed it, I need to delete it. But I have found this in the help:

Saving the agent changes the owner immediately. However, if you subsequently get the owner within the same NotesSession, the previous owner’s name is returned. The ownership change is not reflected in the properties until the next time a Session is obtained.

A script has only one Domino session, so successive calls to the New method return the same session handle.

So I have to call another agent to get a new NotesSession handle to delete the agent?

I want to delete the agent so I can install a new version of it. It is part of an uninstall/re-install function that will be used outside my domain.

Subject: RE: agent.save on manual agent does not change owner

Are you trying to do these modification to the agent you are currently running?The agents cannot perform operations on themselves - like enabling themselves and then saving. It generates problems similar to replications problems (except you don’t see them because they are design documents). We (Domino framework) make all kinds of modifications to the agent (like updating agent log, saving the info when the agent run last, what documents it processed) and if the agent tries to make modifications to itself there is a conflict.

The information in the session about the current agent is cached (reading it from disk every time we need some information would slow things down quite a bit).

It would work better if you use another agent to perform operations on your agent.

Subject: RE: agent.save on manual agent does not change owner

I am running 1 agent to install/un-install multiple agents. The un-install agent loops through a set of agents within the database and removes each one. Once they are removed, the same agent then calls a function to re-install them. I ran into a problem when 1 of the agents I was trying to remove gave me the error about not being able to remove agents not belonging to me. Now I have that resolved (by setting agent.Server and saving it), but I need a new NotesSession to recognize the new agent owner (me)…which requires another agent… am I right?