Avatar of Harsh Kumar
Harsh Kumar
Flag for Denmark asked on

Lotus Notes, Agent - installation / distrubtion of a agent into mail db

Hi Guys!

I need some help with figuring out how to distribute a agent to our users.

We have limited designer/admin rights, but do have rights to create a agent in the mail db.

I have create and agent and want to install / distribute it to users without they need to copy paste the code it self.

Is there any possibility for this?

My dream scenario would be:

The agent is put into its own database, which will be distributed. create a button in that which will copy the agent into the mail database, just like if you would do in the View -> Agents, right click on the agent and copy, and paste it into the mail database..

is this possible?
Lotus IBM

Avatar of undefined
Last Comment
Harsh Kumar

8/22/2022 - Mon
Sjef Bosman

What type of agent is it? Will it be used once, or regularly? Should it stay there, in the mail database? And how about updating the agent, did you think about that?

Anyway, the server can do this for you. Normally, and I don't really like it either but it's the best way, you'd modify the mail template and add the agent in the template. When the Designer task runs (which is normally at night, unless you disabled it), it distributes the updates to every mail database. No need for manual updates.

Suggested procedure:
- make a Notes copy of the mail template you use (mail85.ntf or so), e.g. to mail85x.ntf
- give the template a different template name (see the Properties tab)
- add your agent
- change the template name of your own mail database to the new name, and refresh its design
- check whether the agent is added

Of course, this only works when you are the Admin for the server, you have the Designer client, and you also have sufficient rights to modify the design of a database. If that's not you, I suggest you ask someone who has these requirements. If it's really that important that every user should have the agent, you need the support of your manager.

If you're on your own, forget it. IMHO doing it all by yourself is bound to fail.
Harsh Kumar

ASKER
Thank you for your feed back Sjef!

This would be the way it should be done and this is the correct way i agree! sadly the rights are limited on the database.
The admin has down prioritized this case for over 2 years now... for such a simple addition that would make life easier for tons of people.. but sadly its bureaucracy that is holding the changes back. the administration are centralized but we are allowed to make changes for 1 territory , but they will implement when they feel the need or when they have "time" (this is how we see in from a users point of view).

that said, all i'm looking for is a way to copy an agent from one database to another, a simple code that would do so... i have googled it alot but sadly i found something which i'm not fully understanding... thats why this post to maybe find a alternative..

this is the code i found:
set view=dbSource.Getview("ViewName")
set doc=dbSource.GetdocumentByUnid
("ViewName.UniversalId")
call doc.CopytoDatabase(dbDestination)

Open in new window


This is the source (i'm note sure if its allowed to link to other websites, so sorry in advance):
http://searchdomino.techtarget.com/answer/Can-LotusScript-copy-an-agent-from-one-database-to-another


I know its possible to copy documents from 1 database to another so why not a agent?
captain

I wonder, and sjef may be able to answer this, if you do not have the permission rights to modify the design template, will you agent run in that db?

When you create the agent the current user ID will be used to sign the agent, and this needs to have appropriate permissions in the ACL to run.

So you may be able to create the agent and save it in the db, but it will simply fail to execute due to security restrictions. As agents are very powerful I would expect that to be the case if admin are keen to keep things "tidy".

capt.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Harsh Kumar

ASKER
Additional info:

It's a agent that do a mail merge from a excel file into a stationary from the mail template. Yes, it should stay there.

this is the code:

Declarations:

%Include "lsconst.lss"


---------------------------------

Initialize:


Sub Initialize
	'Mail merge script 
	
	Dim ws As NotesUIWorkspace
	Set ws = New NotesUIWorkspace
	Dim sendTypes(1) As String
	Dim sendValue As String
	Dim errorCount As Integer
	errorCount = 0
	sendTypes(0) = "Draft messages without sending"
	sendTypes(1) = "Send messages"
	sendValue = ws.Prompt(PROMPT_OKCANCELLIST, "Sending options", "What would you like to do?", "", sendTypes)
	If (sendValue = "") Then
		Exit Sub
	End If
	
	Dim fileName As String
	Dim strXLFilename As String
	'Prompt for the filename - should be a Microsoft Excel file with columns, where the first row of each column
	'is a token that will be used when replacing text in the body of the message
	'Special tokens: [to], [cc], [subject] set the appropriate fields
	'Make sure the first column does not have any blank cells
	fileName$ = ws.Prompt(12, "Select file", "3")
	If fileName$ = "" Then
		Exit Sub   'Cancel was pressed
	End If
	strXLFilename = fileName$
	Dim s As New NotesSession
	Dim uidoc As NotesUIDocument
	Dim partno As String
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim doc As NotesDocument
	Dim collection As NotesDocumentCollection
	Dim memo As NotesDocument
	Dim body As NotesRichTextItem
	Dim newBody As NotesRichTextItem
	Dim range As NotesRichTextRange
	Dim count As Integer
	
	Set db = s.CurrentDatabase
	Set collection = db.UnprocessedDocuments
	Set memo = collection.getFirstDocument()
	
	Dim varXLFile As Variant
	'Get data from the spreadsheet
	Set varXLFile = CreateObject("Excel.Application")
	varXLFile.Visible = False
	Dim varXLWorkbook As Variant
	Set varXLWorkbook = Nothing
	varXLFile.Workbooks.Open strXLFilename
	Set varXLWorkbook = varXLFile.ActiveWorkbook
	Dim varXLSheet As Variant
	Set varXLSheet = varXLWorkbook.ActiveSheet
	
	Dim lngRow As Integer
	Dim columnNo As Integer
	Dim token As String
	Dim value As String
	lngRow = 2
	Dim maildoc As NotesDocument
	While (Not (varXLSheet.Cells(lngRow, 1).Value = ""))
		'Fill in the template
		Dim subject As String
		subject = memo.Subject(0)
		Set body = memo.GetFirstItem("Body")
		
		'Compose message
		
		Set maildoc = New NotesDocument(db)
		Set maildoc= db.CreateDocument()
		maildoc.Form = "Memo"
		maildoc.Subject = subject
		Set newBody = maildoc.CreateRichTextItem("Body")
		Call newBody.appendRTItem(body)
		Set range = newBody.CreateRange			
		
		'Count the number of fields
		'Look up tokens from the column headings and replace them
		columnNo = 1
		While Not(varXLSheet.Cells(1, columnNo).Value = "")
			token = varXLSheet.Cells(1, columnNo).Value
			value = varXLSheet.Cells(lngRow, columnNo).Value
			count = range.FindAndReplace(token, value, 16)
			If (token = "[to]") Then
				maildoc.SendTo = value
			End If
			If (token = "[cc]") Then
				maildoc.CopyTo = Split(value, ",")
			End If
			If (token = "[subject]") Then
				maildoc.Subject = value
			End If
			columnNo = columnNo + 1
		Wend
		On Error GoTo save
		If (sendValue = sendTypes(0)) Then
			Call maildoc.Save(True, False)
		Else
			maildoc.SaveMessageOnSend = True
			maildoc.PostedDate = Now()
			Call maildoc.Send(False)
			Call maildoc.Save(True, True)
		End If
		GoTo nextrow
save:
		MessageBox("Error processing " + maildoc.sendTo)
		errorCount = errorCount + 1
		Resume Next
nextrow:
		lngRow = lngRow + 1
	Wend
	If (sendValue = sendTypes(0)) Then
		MsgBox "Drafted " & (lngRow - errorCount - 2) & " message(s). Errors: " & errorCount
	Else
		MsgBox "Sent " & (lngRow - errorCount - 2) & " message(s). Errors: " & errorCount
	End If
	Call varXLFile.Quit
	
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Sjef Bosman

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Fredrik Norling

Hi,

If the users doesn't have access to the database you will not be able to add a agent to the users database.

the general ways to do this is
1. copy the agent to the database using a button inside an email
2. Add the code inside an email in a button and act on all documents inside i.e a folder
3. Add the agent into another database that you distribute and the users add locally on their notes client.
and this database has design that can act on the documents in the users mail database
Harsh Kumar

ASKER
Thank you guys!

@Sjef - I totally understand you point and i'm kinda running my head into the wall here... so i'm open for alternatives like your suggestion C, i have tried to look at some posibilites to rewrite the code i have into vba, although my vba is really rusty almost equal to none existing, so if any of you have some guidance or earlier posts that solves the need please advise.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.