LinkIDMAttachments
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
Syntax
Dim linkStatus As Integer = LinkIDMAttachments(targetSymbol, targetCode, sourceSymbol, sourceCode, functionCode, filename, offset, limit)
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. |
offset |
The starting index for the object search. |
limit |
The maximum number of records you can search using the value specified in the offset. |
Example
Option Strict Off
Imports System
Imports System.Diagnostics
Class ActionScript
Inherits FcProcFuncSetEventWF
Function wf_start() As Long
Dim linkStatus as Integer
' LinkIDMAttachments(targetSymbol, targetCode, sourceSymbol, sourceCode, functionCode, filename(s), offset, limit)
linkStatus = LinkIDMAttachments(_OBJECTSYMBOL, _OBJECTKEY, "ITEM", "ITEM4", "IDM_TEST", "Lion.jpg", 0, 1000)
if linkStatus = 1 then
MessageList("Attachments are linked to object Successfully.")
else if linkStatus = 0 then
MessageList("Some or no attachments are linked.")
else
MessageList("Error in linking Attachment to Object.")
end if
MessageList("Attaching Single files")
End Function
End Class
Syntax (for overload method)
Dim linkStatus As Integer = LinkIDMAttachments(cMItems, targetSymbol, targetCode)
linkStatus = LinkIDMAttachments(cMItems, _OBJECTSYMBOL, _OBJECTKEY)
if linkStatus = 1 then
MessageList("Attachments are linked to object Successfully.")
else if linkStatus = 0 then
MessageList("Some or no attachments are linked.")
else
MessageList("Error in linking Attachment to Object.")
end if
MessageList("Attaching Single files")
End Function
End Class
Arguments
Parameter | Description |
---|---|
cMItems |
The target object to which you can link the attachment. |
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". |
Example
Option Strict Off
Imports System
Imports System.Diagnostics
Imports Infor.DocumentManagement.ICP
Class ActionScript
Inherits FcProcFuncSetEventWF
Function wf_start() As Long
Dim symbol as String = "ITEM"
Dim objCode as String = "ITEM75"
Dim fileName as String = "Tiger.jpg"
Dim sQry as String = "/IDM_TEST[@OPTIVA_SYMBOL = """ & symbol & """ AND @OPTIVA_SYMBOL_ID = """ & objCode &"""]"
Dim idmHelper as new FsLibIDMHelper(me)
Dim cMItems As CMItems = idmHelper.GetDocuments(sQry)
Dim linkStatus as Integer
' LinkIDMAttachments(cMItems, targetSymbol, targetCode)
linkStatus = LinkIDMAttachments(cMItems, _OBJECTSYMBOL, _OBJECTKEY)
if linkStatus = 1 then
MessageList("Attachments are linked to object Successfully.")
else if linkStatus = 0 then
MessageList("Some or no attachments are linked.")
else
MessageList("Error in linking Attachment to Object.")
end if
MessageList("Attaching Single files")
End Function
End Class