Converting File Names for Files Uploaded by 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.

Related Topics