LinkIDMAttachments

You can use this function for Optiva Workflows.

Purpose

This function is used to link IDM attachments from one source object to another target object in Optiva. You specify the function code and file(s) that you want to link between both the source and target object.

Syntax

Dim linkStatus As Integer = LinkIDMAttachments(targetSymbol, targetCode, sourceSymbol, sourceCode, functionCode, fileName)

The function returns 1 if successful, 0 if there is an error.

Arguments

Parameter Description
targetSymbol Optiva Object Symbol to which you want to link the attachment. For example, you can link an attachment to another "Formula" or "Item".
targetCode

Optiva Object to which you want to link the attachment. For example, you can link an attachment to "ITEM001" or "FORMULA1\0001".

sourceSymbol

Optiva Object Symbol that already has the attachment that you want to link to the target object.

For example, the symbol for the source object can be a "Formula" or an "Item".

sourceCode

Optiva Object that already has the attachment that you want to link to the target object.

For example, "ITEM001" or "FORMULA1\0001" already has the attachment that you want to link to the target object.

functionCode An IDM Doc Code to which the file is already attached in the source object.
fileName

The name of the file that you want to link between the source and target object. Include the file extension in the file name. For example "sample.jpg", "test.txt".

For a single file, specify a string for the file name. For multiple files, specify a list of file names, including the file extensions.

Specifying multiple files

When you specify multiple files, the files should be passed as a list. For example:


Dim files As New List(Of String)
files.Add("desert.jpg")
files.Add("samplepic1.jpg")

Example for linking attachments from a source object to a target object

This example shows you how to create a formula, REPL001\0001, and link documents from an existing item, 00001, to the new formula. A value of 1 is returned when the process is successful.

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports System.Diagnostics

Class ActionScript
Inherits FcProcFuncSetEventWF

Function wf_approve() As Long
Dim sformCode As String = GenerateCodeNumber("NEW FORMULA")
Dim exists as long = ObjectExists(sformCode ,"FORMULA")
if exists = 1 then
   MessageList("Formula already exists.")
else
Dim saveStatus as long = ObjectSaveAs("FORMULA", "TEMPLATE",sformCode)
if saveStatus >= 0 then
StartForm("frmformula",sformCode)

'Attaching Single file

Dim linkStatus as Integer

linkStatus = LinkIDMAttachments("FORMULA", sformCode, "FORMULA", "REPL001\0001", "ATTACH_DOCUMENTS_TEST", "samplepic.jpg")

if linkStatus = 1 then
   MessageList("Attachment is linked to object Successfully")
else
   MessageList("Error in linking Attachment to Object")
end if

'Attaching multiple files

Dim files As New List(Of String)
files.Add("desert.jpg")
files.Add("samplepic1.jpg")

linkStatus = LinkIDMAttachments("FORMULA", sformCode, "FORMULA", "REPL001\0001", "ATTACH_DOCUMENTS_TEST", files)

if linkStatus = 1 then
   MessageList("Attachments are linked to object Successfully")
else
   MessageList("Error in linking Attachments to Object")
end if
else
   MessageList(sformCode  & " was not created.")
end if
end if
return 111
End Function
End Class