Agent Delete Error: Cannot remove agent belonging to another user

Mindwatering Incorporated

Author: Tripp W Black

Created: 10/02/2011 at 11:04 AM

 

Category:
Notes Developer Tips
Agents, LotusScript

Issue:
You are trying to remove an agent that you previously added via script. However, the application has been resigned since then in production. Later powers-that-be change their mind and wish the agent removed. You try to myAgent.Remove() but get the error:
4272 Cannot remove agent belonging to another user.

Solution:
You need to sign it again and remove all references/hooks to the agent as an object. Then you should be able to finally delete (remove) it.

Sample code:

If Not (mAg Is Nothing) Then
' agent already exists, delete agent
Print "Application: " & mdbpath & ", has agent. Deleting . . ."
' need to update agent to this current user, otherwise cannot delete "cannot remove agent belonging to another user"
mAg.servername = "deleteme"
Call mAg.Save
Delete mAg ' remove reference hooks by calling internal agent's deletion sub (this may actually do the remove, too)
If Not (mAg Is Nothing) Then
Call mAg.Remove()
End If
ProcessPerson = 1
Else
' check by alias
Set mAg = mDb.GetAgent(agtitle2)
If Not (mAg Is Nothing) Then
Print "Application: " & mdbpath & ", has agent. Deleting . . ."
' need to update agent to this current user, otherwise cannot delete "cannot remove agent belonging to another user"
mAg.servername = "deleteme"
Call mAg.Save
Delete mAg ' remove reference hooks by calling internal agent's deletion sub (this may actually do the remove, too)
If Not (mAg Is Nothing) Then
Call mAg.Remove()
End If
ProcessPerson = 1
Else
' agent doesn't exist, skip
' Print "Application: " & mdbpath & ". Agent doesn't exist. Skipped."
ProcessPerson = 1
End If
End If


previous page