DocExist

The DocExist function checks for text entries and file attachments associated with a function code on a specified Optiva object. The function returns a numeric value indicating the type of content available.

When to use

You can use this function to:

  • Check for the presence of text entries and file attachments for a function code.
  • Check document availability during workflow execution or Copy Methods.

When not to use

You cannot use this function:

  • For publishing documents. The function checks for existing text and attachments.
  • For IDM Documents or IDM links.

Syntax

int DocExist(string objSymbol, string objkey, string funcCode);

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, "REPORT", "WEB").

Return Value

Attachments Text Return Value Meaning
Invalid function code Invalid function code -1 Function code is invalid or does not exist.
No No 0 Neither text nor attachments exist.
No Yes 1 Only text exists. (no attachments)
Yes No 2 Only attachments exist.(no text)
Yes Yes 3 Both text and attachments exist.

Prerequisites

  • Files need to be in a shared location available to the application server.
  • No special user permissions are required. The function operates with server permissions rather than user permissions.

Examples

Example 1
Check for report attachments.
// Check for report on specific formula
int iText = DocExist("FORMULA", "PIZZASAUCE\\003", "REPORT");

if (iText < 1)
{
    MessageList("You must attach a report.");
}
Description
This example checks for the presence of text and attachments to a workflow formula. The formula code is PIZZA_SAUCE\003. If none are detected, a message is displayed to the user.
Example 2
Check for safety documents and control workflow.
public long wf_start()
{
    int iText = DocExist("", "", "SAFETY");
    if (iText == 1 || iText == 3) return 111L; // preferred (explicit long literal)
    MessageList("There are no Safety documents. Include some.");
    return 1L;
}
Description
This example checks for the presence of text in the SAFETY function code for the workflow object or new object. If there is none, a message is displayed to the user.
Example 3
Check for text in a function code(COMMENT)
// Check for text or attachments in the COMMENT function code 
int iDoc = DocExist("", "", "COMMENT"); 
  
MessageList("Checking COMMENT function code..."); 
  
switch (iDoc) 
{ 
    case -1: 
        MessageList("Invalid function code: COMMENT"); 
        break; 
    case 0: 
        MessageList("No COMMENT text or attachments found."); 
        break; 
    case 1: 
        MessageList("COMMENT text exists, but no attachments."); 
        Break; 
    default: 
        MessageList("Unexpected return value: " + iDoc); 
        break; 
}
Description
This example checks for an attachment to the WEB function code for the workflow object or new object. If there is none, a message is displayed.