Application Development Considerations

This section discusses:

  • File name considerations.

  • Restrictions on invoking functions in certain PeopleCode events.

  • Converting file names for files uploaded by PutAttachment.

  • Considerations when using CopyAttachments.

If the source file name specified using one of the file attachment. contains any of the following characters, the invoking function will be stopped and an error (%Attachment_Failed) is returned. The actual error message can be found in the logs.

  • * (asterisk)

  • : (colon)

  • " (quotation mark)

  • < (less than symbol)

  • > (greater than symbol)

  • ? (question mark)

When the file is uploaded to or downloaded from a storage location, the following characters are replaced with an underscore:

  • (space)

  • @ (at sign)

  • ; (semicolon)

  • + (plus sign)

  • % (percent sign)

  • & (ampersand)

  • ' (apostrophe)

  • ! (exclamation point)

  • # (pound sign)

  • $ (dollar sign)

Note: In general, you should exercise caution when using an @ or : character in the name of a file selected for uploading. In FTP URLs, the : character must to be used as a delimiter between the FTP user ID and the FTP password or just before the FTP port number (if one is specified). In addition, in FTP URLs, the @ character must be used as a delimiter between the FTP password and the FTP server address.

Because AddAttachment, DetachAttachment, MAddAttachment, and ViewAttachment are interactive, they are known as “think-time” functions. This means that these functions should not be used in any of the following PeopleCode events:

  • SavePreChange

  • SavePostChange

  • Workflow

  • RowSelect

  • Any PeopleCode event that initiates as a result of a Select or SelectNew method, or any of the ScrollSelect functions.

If you want to transfer files in a non-interactive mode with functions that aren't think-time functions, see GetAttachment and PutAttachment.

Generally, a PeopleCode program that calls PutAttachment will also need to save (for later use) the name of each uploaded file as it ended up actually being named at the specified storage location. However, the destination file name (which may have been converted as described in “File Name Considerations”) is not passed back to the PutAttachment function. So, the only way for your PeopleCode program to ensure that it is saving the correct name is to either avoid using special characters in the destination file name or to simulate the conversion process in something like the following example:

&ATTACHUSERFILE = Substitute(&ATTACHUSERFILE, " ", "_"); 
&ATTACHUSERFILE = Substitute(&ATTACHUSERFILE, ";", "_"); 
&ATTACHUSERFILE = Substitute(&ATTACHUSERFILE, "+", "_"); 
&ATTACHUSERFILE = Substitute(&ATTACHUSERFILE, "%", "_"); 
&ATTACHUSERFILE = Substitute(&ATTACHUSERFILE, "&", "_"); 
&ATTACHUSERFILE = Substitute(&ATTACHUSERFILE, "'", "_"); 
&ATTACHUSERFILE = Substitute(&ATTACHUSERFILE, "!", "_"); 
&ATTACHUSERFILE = Substitute(&ATTACHUSERFILE, "@", "_"); 
&ATTACHUSERFILE = Substitute(&ATTACHUSERFILE, "#", "_"); 
&ATTACHUSERFILE = Substitute(&ATTACHUSERFILE, "$", "_");

Note: Unlike the PutAttachment function, the AddAttachment function automatically returns the converted file name for reference and later use. For example, the file name My Resume.doc is returned through the AddAttachment function as My_Resume.doc, with the space converted to an underscore.

CopyAttachments does not modify the contents of any of the associated file reference tables. You must design your application in such a way that using CopyAttachments does not, by itself, require any subsequent changes to the contents of any of the associated file reference tables.