DocAddAttach

You can use the DocAddAttach function to associate a file with an Optiva object by creating an attachment link. The function does not publish documents. It attaches files that are in a shared location accessible by the application server.

When to use

You can use this function to:

  • Automatically attach generated reports, batch records, or documentation files during workflow execution.
  • Link existing files from shared network locations to Optiva objects without duplicating storage.

When not to use

You cannot use this function for publishing documents. The function only creates attachment links not publishing documents.

Syntax

int DocAddAttach(string objSymbol, string objkey, string funcCode, string fileStr);
int DocAddAttach(string objSymbol, string objkey, string funcCode, string fileStr, string link);
int DocAddAttach(string objSymbol, string objkey, string funcCode, string fileStr, string link, string description);

Parameters

Parameter Type Required Description
objSymbol string Optional

The symbol of the object.

Note: You can use empty quotation marks ("") for the current workflow symbol.
objKey string Optional

The key of the object.

Note: You can use empty quotation marks ("") for the current workflow symbol.
funcCode string Yes The function code for the attachment (For example, "CHANGES", "SOP", "MSDS").
fileStr string Yes The file name to display in the user interface. Name and path of the source file to attach.
Note: 
  • If you do not use the link argument, include the path to the file name.
  • If you use the link argument, a path is not required.
  • The value does not have to be an actual file name; you can specify any name for display in the list of attachments in the user interface.
link string Optional The full path/link to the file location accessible by the application server.
description string Optional The description text to display in the user interface.

Return Value

The application returns a value greater than zero (0) if the operation is successful.

Prerequisites

  • The file needs to be in a shared location accessible by the application server.
  • No special user permissions are required because the function operates with server permissions rather than user permissions.

Examples

Example 1
Attach ChangeHistory.txt to current formula.
//Attach ChangeHistory.txt (file already published on the application server share)

long rc1 = DocAddAttach("", "", "CHANGES", "ChangeHistory.txt", @"\\server01\optiva\attached_files\ChangeHistory.txt", "Recent Changes");

//Attach a versioned copy instead (unique version of the file in published area)

long rc2 = DocAddAttach("", "", "CHANGES", "ChangeHistory.txt", @"\\server01\optiva\attached_files\ChangeHistory_Version07.txt", "Recent Changes");