Search

GlobalSCAPE Knowledge Base

How do I use the COM API to copy (duplicate) Advanced Workflows or import existing Workflow files (.aml)?

Karla Marsh
EFT

THE INFORMATION IN THIS ARTICLE APPLIES TO:

  • version 6.5 and later

QUESTION

How do I use the COM API to copy (duplicate) Advanced Workflows or import existing Workflow files (.aml)?

ANSWER

To copy and import workflows using the COM API, you can to use the Site methods AddAdvancedWorkflow and GetAdvancedWorkflowParams.

MORE INFORMATION

Review the examples below, or download the attached examples (scroll to the bottom of page for the attachment). Don’t forget to change your admin login credentials in the script and point to the correct Site index (set to Site ‘0’ by default, meaning the first Site created in EFT).

(You can also copy and import AWE workflows in the EFT administration interface.)

Copy Workflow:

' INBOUND parameters {{{
strSourceAWTaskName = "AWTask"
strDestinationAWTaskName = strSourceAWTaskName + "_Copy"
strServer = "localhost"
strPort = "1100"
strAdminUserName = "a"
strPassword = "q"

' }}} INBOUND parameters

' Get CISite object {{{
Set objEFTServer = CreateObject("SFTPCOMInterface.CIServer")
objEFTServer.Connect strServer, strPort, strAdminUserName, strPassword

set objSites = objEFTServer.Sites
set objSite = objSites.Item(0)
' }}} Get CISite object

' Get source AW task script content {{{
' Get source AW task index
nSourceAWTaskIndex = objSite.GetAdvancedWorkflowIndex(strSourceAWTaskName)

' Get source AW task parameters by index
Set objSourceAWTaskParams = objSite.GetAdvancedWorkflowParams(nSourceAWTaskIndex)

' Get source AW task script content
strSourceScriptContent = objSourceAWTaskParams.Code
' }}} Get source AW task script content

' Copy AW Task {{{
Set objDestinationAWTaskParams = CreateObject("SFTPCOMInterface.CIAdvancedWorkflowParams")

' Set new AW task name
objDestinationAWTaskParams.Name = strDestinationAWTaskName

' Set script content for new AW task
objDestinationAWTaskParams.Code = strSourceScriptContent

' Add new AW task to EFT
objSite.AddAdvancedWorkflow(objDestinationAWTaskParams)

' }}} Copy AW Task

MsgBox "Done."

Import Workflow:

' INBOUND parameters {{{
' Outside script which we want to import
strFileToImport = "C:\\SomeOutsideScript.aml"

' EFT AW task name for imported script
strAWTaskName = "AWTask_Imported"

strServer = "localhost"
strPort = "1100"
strAdminUserName = "a"
strPassword = "q"

' }}} INBOUND parameters

' Read outside script contents {{{
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objReadFile = objFSO.OpenTextFile(strFileToImport, 1, False)

strFileContents = objReadFile.ReadAll

objReadFile.close

Set objFSO = Nothing
Set objReadFile = Nothing
' }}} Read outside script contents

' Get CISite object {{{
Set objEFTServer = CreateObject("SFTPCOMInterface.CIServer")
objEFTServer.Connect strServer, strPort, strAdminUserName, strPassword

set objSites = objEFTServer.Sites
set objSite = objSites.Item(0)
' }}} Get CISite object

' Add AW Task to EFT server {{{
Set objAWParams = CreateObject("SFTPCOMInterface.CIAdvancedWorkflowParams")
objAWParams.Name = strAWTaskName
objAWParams.Code = strFileContents

objSite.AddAdvancedWorkflow(objAWParams)
' }}} Add AW Task to EFT server

MsgBox "Done."

Details
Last Modified: 2 Years Ago
Last Modified By: kmarsh
Type: FAQ
Rated 1 star based on 4 votes.
Article has been viewed 34K times.
Options
Also In This Category
Tags