Is there an documentation or an easy solution how i can activate the out of office service in an user mailfile with an external run on server agent?
I tried it like this, but it does not work...
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim dt As New NotesDateTime(Now)
Set db = s.Getdatabase("SERVERNAME", "MAILFILE")
Set doc = db.Createdocument()
doc.AppointmentType= "2"
doc.BookFreeTime = ""
doc.CreatedByAgent = "1"
doc.ExcludeFromView = "D"
doc.Form = "Appointment"
doc.From = s.Username
doc.Principal = s.Username
Call doc.Replaceitemvalue("$BusyName","")
Call doc.Replaceitemvalue("$BusyPriority","")
Call doc.Replaceitemvalue("$PublicAccess","1")
doc.ApptUNID = doc.Universalid
Call dt.Adjustday(-5)
set doc.EndDate = dt
set doc.EndDateTime = dt
call dt.Adjustday(10)
set doc.StartDate = dt
set doc.STARTDATETIME = dt
doc.Subject = "Out Of Office"
Call doc.Replaceitemvalue("$UpdatedBy",s.Username)
Call doc.save(True,False)
Set doc = db.Getprofiledocument("OutOfOfficeProfile")
Call dt.Adjustday(-5)
Set doc.FirstDayOut = dt
Call dt.Adjustday(10)
Set doc.FirstDayBack = dt
doc.CurrentStatus = "1"
doc.GeneralSubject = "HE IS NOT AVAILABLE"
Call doc.save(True,false)
UPDATE (changed answer from Out of office agent activation to Out of office service activation):
Look in MailFile ScriptLibrary OutOfOfficeLib in Class OutOfOfficeObj for method EnableService(). There is the code you have to adapt and put in your agent.
With the code line
Call db.SetOption( DBOPT_OUTOFOFFICEENABLED, True)
you activate the Out of Office service. There are some other settings you probably have to do in addition. Just follow the called methods in EnableService() and figure out what is really necessary.
Here is a good description how to activate and how to deal with issues with Out of Office service. Changes in users Out of Office service status e.g. might be visible only after sending the user an email.
This is the way how it works.
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim dt As New NotesDateTime(Now)
Set db = s.Getdatabase("SERVER", "MAILFILE")
Set doc = db.Getprofiledocument("OutOfOfficeProfile")
Call dt.Adjustday(-5)
Set doc.FirstDayOut = dt
Set doc.StartTime = dt
Call dt.Adjustday(10)
Set doc.FirstDayBack = dt
Set doc.EndTime = dt
doc.CurrentStatus = "1"
doc.GeneralSubject = "MESSAGE"
doc.TaskState = "1"
doc.CurrentSate = "1"
doc.ShowHours = ""
Call doc.Computewithform(false, false)
Call doc.save(True,false)
Call db.SetOption( DBOPT_OUTOFOFFICEENABLED, True)
Related
I would like to ask if it is possible to pass parameters (for example: fieldA and fieldB value) from Database1 using an agent, and triggering Database2-agent to accept the parameter being passed?
Not sure if it's possible. Thank you!
There is a -partly undocumented- function to pass a complete in- memory document to an agent without saving it. Like that you can pass anything from one agent to another. But it only works if one agent calls the other:
Dim ses as New NotesSession
Dim db2 as NotesDatabase
Dim agent2 as NotesAgent
Dim docTemp as NotesDocument
Set db2 = New NotesDatabase( "Server", "db2Path.nsf" )
Set agent2 = db2.GetAgent( "NameOfAgent2" )
Set docTemp = New NotesDocument( db2 )
docTemp.Parameter1 = "Some string"
docTemp.Parameter2 = "Another String"
docTemp.AnyNameYouWant = 3
Call agent2.runWithDocumentContext( docTemp )
Then in the agent two you access the document like:
Dim ses as New NotesSession
Dim docTemp as NotesDocument
Set docTemp = ses.DocumentContext
param1 = docTemp.Parameter1
param2 = docTemp.Parameter2
numParam1 = docTemp.AnyNameYouWant
I'm using IBM Designer 9.0, so I have a problem with sending notifications to notebooks.
I test this code which I find on the internet but it does not work.
Sub CreateMailNotification(doc As notesdocument, strSendTo As Variant, strSubject As String, strCopyTo As Variant)
Dim session As notessession
Dim db As notesdatabase
Dim docMail As notesdocument
Dim rtitem As Variant
Set db = doc.parentdatabase
Set session = db.Parent
Set docMail=db.createdocument
Set rtitem=docMail.CreateRichTextItem(“Body”)
If strSendTo(0)=”” Then Exit Sub
‘=====set mail
docMail.Form = “Memo”
docMail.From = session.UserName
docMail.Principle = session.UserName
docMail.SendTo = strSendTo
If Isarray(strCopyTo) Then
If strCopyTo(0)<>”” Then
docMail.CopyTo = strCopyTo
End If
Else
If strCopyTo<>”” Then
docMail.CopyTo = strCopyTo
End If
End If
docMail.Recipients = strSendTo
docMail.Subject = strSubject
docMail.PostedDate = Now
‘=====set body field
Call rtitem.AppendText(“Please click this doclink to see more details about the status ” + ” “)
Call rtitem.AppendDocLink( doc, “click to open document”)
Call rtitem.AddNewLine( 2 )
‘=====send mail
Call docMail.send(False)
End Sub
call Call CreateMailNotification (doc, doc.nmSendTo, strSubject,doc.nmCopyTo)
I have a problem with these two lines
Call rtitem.AppendText(“Please click this doclink to see more details about the status ” + ” “)
Call rtitem.AppendDocLink( doc, “click to open document”)
Call rtitem.AddNewLine( 2 )
Typically an rtitem is a rich text item being referenced in the document. As has ben suggested before, you can do a simple error checking by doing an "onerror goto" or you can turn on the lotusscript debugger, "tools...\debug lotusscript", and step through the code (this is what I like), or you can do print statements at different places in your code: "print 1". That would display at the bottom on the status bar. Or you can even do a "messagebox( 'test')" to have a popup. Lots of options. The last two options I use all the time when debugging for the web. I use Print "<Script Language = JavaScript>" Print "alert('" + "Testing" + "')" Print "</Script>"
This gives me places where i get prompts, and when they stop, somewhere after the last one and before the next one is where its crashing.
I would like to automatize the process of SSL certificate installation for IIS 7.5. The preferred way is to use VBScript. I work on the problem to create a new HTTPS binding and to bind correct certificate to this binding.
I actually solved this problem activating Add IIS Management Scripts and Tools role for my web-server and using script like this:
Set serverWebAdmin = GetObject("winmgmts:root\WebAdministration")
' EC8BCFF70983EA26BFEA087683329CB8C07366A5 is an certificate hash of the fake certificate
' that i obtain from the staging environment of Let's Encrypt
' "MY" is the name of certificate storage
serverWebAdmin.Get("SSLBinding").Create "*", 443,"EC8BCFF70983EA26BFEA087683329CB8C07366A5", "MY"
Set newBinding = serverWebAdmin.Get("BindingElement").SpawnInstance_
newBinding.BindingInformation = "*:443:"
newBinding.Protocol = "https"
Set issuedWebSite = serverWebAdmin.Get("Site.Name='sitename.com'")
webSiteBindings = issuedWebSite.Bindings
ReDim Preserve webSiteBindings(UBound(webSiteBindings) + 1)
Set webSiteBindings(UBound(webSiteBindings)) = newBinding
issuedWebSite.Bindings = webSiteBindings
Set pathResult = issuedWebSite.Put_
It works well but before to use WMI to manage the server i tried to use (and expand a little) an example from MSDN how to create a binding. I took the example on VBScript and added the declaration of certificate hash and certificate storage name (i checked also these properties, they are existing so seems to be possible to set them. I also checked the code of some open-source projects like WinAcme - written in C# - and they use the same properties).
So my code was looking like this (the part that sets properties of binding):
Set bindingElement1 = bindingsCollection.CreateNewElement("binding")
bindingElement1.Properties.Item("protocol").Value = "https"
bindingElement1.Properties.Item("bindingInformation").Value = "*:443:"
bindingElement1.Properties.Item("certificateHash").Value = "EC8BCFF70983EA26BFEA087683329CB8C07366A5"
bindingElement1.Properties.Item("certificateStoreName").Value = "MY"
bindingsCollection.AddElement(bindingElement1)
adminManager.CommitChanges()
It works BUT it only creates the binding and DOES NOT append good certificate to this binding. My problem is solved by the previous code snippet but I would like to understand: is it the second code snippent wrong? Is it possible to bind good certificate this way?
Thank you by advance.
The reason it did not work with your bindingElement1 variant is simply because you can't add it to the bindingCollection, instead you have to add it to a method:
First part which you already had:
Dim bindingElement1 As ConfigurationElement = bindingsCollection.CreateElement("binding")
bindingElement1("protocol") = "https"
bindingElement1("bindingInformation") = "192.168.1.1:443:contoso.com"
bindingsCollection.Add(bindingElement1)
After that simply add:
Dim method = bindingElement1.Methods.Item("AddSslCertificate").CreateInstance()
method.Input.Attributes.Item("certificateHash").Value = "EC8BCFF70983EA26BFEA087683329CB8C07366A5"
method.Input.Attributes.Item("certificateStoreName").Value = "MY"
method.Execute()
Commit changes:
serverManager.CommitChanges()
So in total with some error-catching it could look like this:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim serverManager As ServerManager = New ServerManager
Dim config As Configuration = serverManager.GetApplicationHostConfiguration
Dim sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")
Dim sitesCollection As ConfigurationElementCollection = sitesSection.GetCollection
Dim siteElement As ConfigurationElement = FindElement(sitesCollection, "site", "name", "contoso")
If (siteElement Is Nothing) Then
MsgBox("Element not found!")
End If
Dim bindingsCollection As ConfigurationElementCollection = siteElement.GetCollection("bindings")
Dim bindingElement1 As ConfigurationElement = bindingsCollection.CreateElement("binding")
bindingElement1("protocol") = "https"
bindingElement1("bindingInformation") = "192.168.1.1:443:contoso.com"
Try
bindingsCollection.Add(bindingElement1)
Catch ex As Exception : MsgBox(ex.Message) : End Try
Dim method = bindingElement1.Methods.Item("AddSslCertificate").CreateInstance()
method.Input.Attributes.Item("certificateHash").Value = "EC8BCFF70983EA26BFEA087683329CB8C07366A5"
method.Input.Attributes.Item("certificateStoreName").Value = "MY"
Try
method.Execute()
Catch ex As Exception : MsgBox(ex.Message) : End Try
serverManager.CommitChanges()
End Sub
Private Function FindElement(ByVal collection As ConfigurationElementCollection, ByVal elementTagName As String, ByVal ParamArray keyValues() As String) As ConfigurationElement
For Each element As ConfigurationElement In collection
If String.Equals(element.ElementTagName, elementTagName, StringComparison.OrdinalIgnoreCase) Then
Dim matches As Boolean = True
Dim i As Integer
For i = 0 To keyValues.Length - 1 Step 2
Dim o As Object = element.GetAttributeValue(keyValues(i))
Dim value As String = Nothing
If (Not (o) Is Nothing) Then
value = o.ToString
End If
If Not String.Equals(value, keyValues((i + 1)), StringComparison.OrdinalIgnoreCase) Then
matches = False
Exit For
End If
Next
If matches Then
Return element
End If
End If
Next
Return Nothing
End Function
I am passing parameters to a Java agent from Lotus Script like this:
Set db = session.CurrentDatabase
Set doc = db.CreateDocument
Set uiDoc = workspace.CurrentDocument
Call doc.AppendItemValue("fileName", "SomeString" )
Call doc.Save(True, False)
Set MyAgent = db.GetAgent("AgentName")
Call MyAgent.Run(doc.NoteID)
Set session = New NotesSession
Set db = session.CurrentDatabase
result = doc.GetItemValue("Result")(0)
The agent says the following in Java:
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Agent agent = agentContext.getCurrentAgent();
Database db = agentContext.getCurrentDatabase();
Document doc = db.getDocumentByID(agent.getParameterDocID());
String fileName = doc.getItemValueString("fileName");
doc.appendItemValue("Result","MyResult");
doc.save();
The agent is doing his job correctly. I checked the parameter document and it indeed contains the results from the agent. However, my form is not able to read the Result parameter.
You have to save the doc in your Java code and to re-read your doc in LotusScript after calling your agent.
It is easier to use an In-Memory Document though:
LotusScript
MyAgent.RunWithDocumentContext(doc, doc.NoteID)
Java
Document doc = agentContext.getDocumentContext()
If for some reason you cannot use RunWithDocumentContext (in earlier versions of Lotus Notes) then you need to reopen document:
Set db = session.CurrentDatabase
Set doc = db.CreateDocument
Call doc.AppendItemValue("fileName", "SomeString" )
Call doc.Save(True, False)
noteID$ = doc.NoteID
Set MyAgent = db.GetAgent("AgentName")
Call MyAgent.Run(noteID$)
'Delete document from memory.
Delete doc
'Get updated document.
Set doc = db.GetDocumentByID(noteID$)
result = doc.GetItemValue("Result")(0)
Hi everybody and thanks in advance.
I'm trying to call a SAP BAPI using RFC from vb but I'm having some problem to get the result of the call.
The BAPI "BAPI_GL_ACC_EXISTENCECHECK" (from General Ledger Account module) has two parameters,
COMPANYCODE and GLACCT, and a RETURN parameter.
I wrote this piece of code to make the call and I had no problem to establish the SAP Connection (I use the SAP Logon Control OLE/COM object to do the job), and I tried to make the RFC call.
Also in this case I make the call without problems (it seems, not sure about it ...), because the RFC call returns true and no exception.
However, looking through the objReturn object/parameter, it has a value "Error 0" in it.
I was expecting a complex structure like the BAPIRETURN object in SAP or something similar if the account doesn't exist.
Tried to search with Google and SAP forums but I haven't found a real solution to my problem, so here I am to ask you all if you have some idea to solve this problem (maybe I'm only making a wrong call!!! I'm quite a newbie on SAP integration ...).
BTW, Final Notes: after a lot of RFC_NO_AUTHORIZATION on the SAP side, they gave me a SAP_ALL / S_RFC authorization (sort of, not a SAP expert) and the error RFC_NO_AUTHORIZATION disappeared, but not the Error 0 return
Dim sapConn As Object
Dim objRfcFunc As Object
Dim SAPMandante As String
Dim SAPUtente As String
Dim SAPPassword As String
Dim SAPLingua As String
Dim SAPApplicationServer As String
Dim SAPNumeroSistema As Variant
Dim SAPIDSistema As String
Dim SAPRouter As String
Dim FlagInsertLogin As Integer
Dim FlagLogin As Variant
On Error GoTo ErrorHandler
Set sapConn = CreateObject("SAP.Functions") 'Create ActiveX object
'Silent Logon
SAPMandante = "xxx"
SAPUtente = "yyyy"
SAPPassword = "zzzzzz"
SAPLingua = "IT"
SAPApplicationServer = "www.xxx.com"
SAPNumeroSistema = x
SAPIDSistema = "zzz"
SAPRouter = ""
FlagLogin = SilentLogin(sapConn, SAPMandante, SAPUtente, SAPPassword, SAPLingua, SAPApplicationServer, SAPNumeroSistema, SAPIDSistema, SAPRouter) 'IT WORKS, NO PROBLEM HERE
If FlagLogin = False Then
'Explicit Logon
If sapConn.Connection.logon(0, False) <> True Then
MsgBox "Cannot Log on to SAP", 16, "Query Interrupted"
sapConn.Connection.logoff
Set sapConn = Nothing
InsertCash = False
Exit Sub
End If
End If
'BAPI RFC Call
Set objRfcFunc = sapConn.Add("BAPI_GL_ACC_EXISTENCECHECK")
objRfcFunc.exports("COMPANYCODE") = "C100"
objRfcFunc.exports("GLACCT") = "0000000001" 'Inexistent
Rem *** BAPI CALL ***
If objRfcFunc.Call = False Then
ErrorMsg = objRfcFunc.Exception 'Message collection
MsgBox ErrorMsg, 16, "Errore"
sapConn.Connection.logoff
Exit Sub
else
Dim objReturn As Object
Set objReturn = objRfcFunc.imports("RETURN")
End If
You need to put
Dim objReturn As Object
Set objReturn = objRfcFunc.imports("RETURN")
BEFORE objRfcFunc.Call
i.e. you must state what you're importing from the function before you call it. I usually put it alongside the .exports() lines.
The problem was solved, please take a look at this thread ...
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/sap-rfc-call-returns-error-in-return-parameter-from-vb-before-the-rfc-call-4894968#M4902486