Das Objekt ist laut Optimal Systems der Standarduser vom Server, der dafür genutzt wird, das müsste passen.
Hier ist der Code den ich benutze, um einen Workflow aus einem anderen heraus serverseitig zu starten:
Function StartProcess(sInstanceName)
Dim sName : sName = "StartProcess"
Dim sReturn : sReturn = vbNullstring
Dim oActiveWFModels : Set oActiveWFModels = wfsystem.GetActiveWorkflowmodels
Dim sProcessId : sProcessId = vbNullstring
Dim bFoundModel : bFoundModel = False
Dim oModel
Dim i
For i = 0 To oActiveWFModels.count - 1
Set oModel = oActiveWFModels.item(i)
sModel = oModel.name
If lcase(sInstanceName) = lcase(left(sModel,len(sInstanceName))) Then
bFoundModel = True
Exit For
End If
Next
If bFoundModel Then
set params = oModel.inputvariables
params.item("StartBenutzer").Value = wfvariables.StartBenutzer.Value
set files = oModel.file
sProcessId = oModel.StartProcess (files, params) ' start process
If len(sProcessId) > 0 Then ' successfull
' ...
Else ' not successfull
sReturn = "ERROR can't start subprocess for " & sInstanceName & "."
End If
Set params = Nothing
Set files = Nothing
Set oModel = Nothing
Else
sReturn = "ERROR can't find workflow " & sInstanceName & ". Start subprocess not successfull."
End If
Set oActiveWFModels = Nothing
StartProcess = sReturn
End Function
Und mit diesem Code möchte ich den Prozessverantwortlichen im neu gestarteten Workflow hinzufügen:
Sub AddResponsible(orgid)
On Error Resume Next
If len(orgid) > 0 Then
If Not C_WF_ORG_USER (orgid) Then
rc.logger.error "Kein System User"
Set oUser = wforganisation.GetOrgObjectById(orgid)
If Not oUser is nothing Then
Set listResponsibles = thisprocess.Responsibles
listResponsibles.Add oUser.id, oUser
ThisProcess.Responsibles = listResponsibles
End If
Set oUser = Nothing
End If
End If
On Error Goto 0
End Sub
Bei der Function „C_WF_ORG_USER“ wird geprüft, ob es sich um einen System User handelt und ist dann entweder true oder false.