add_attachment(&URL_ID, &FILEEXTENSION, &SUBDIRECTORY, &FILESIZE, &PREPEND, &RECNAME, &ATTACHSYSFILENAME, &ATTACHUSERFILE, &MESSAGE_LVL, &RETCODE);
&ORIGSYSFILENAME = &ATTACHSYSFILENAME; If &PREPEND And None(&ORIGSYSFILENAME) Then &uniquefilename = ""; &REC = GetRecord(@&RECNAME); For &I = 1 To &REC.FieldCount &Fld = &REC.getfield(&I); If (&Fld.IsKey = True) Then If (&Fld.value = "" And &Fld.IsRequired = True) Then MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 28, "Please attach the file after filling out the required fields on this page."); Return; Else &uniquefilename = &uniquefilename | &Fld.value; End-If; End-If; End-For; &temp = Substitute(&uniquefilename, " ", ""); /* delete spaces */ &ATTACHSYSFILENAME = Left(&uniquefilename, 64); /* make uniq part a max of 64 chars */ End-If; &ATTACHSYSFILENAME = &SUBDIRECTORY | &ATTACHSYSFILENAME; &RETCODE = AddAttachment(&URL_ID, &ATTACHSYSFILENAME, &FILEEXTENSION, &ATTACHUSERFILE, &FILESIZE); /* The actual name on the ftp file server is the following */ If &PREPEND Or All(&ORIGSYSFILENAME) Then &ATTACHSYSFILENAME = &ATTACHSYSFILENAME | &ATTACHUSERFILE; Else &ATTACHSYSFILENAME = &SUBDIRECTORY | &ATTACHUSERFILE; End-If; &temp = Substitute(&ATTACHSYSFILENAME, " ", ""); /* delete spaces */ &ATTACHSYSFILENAME = &temp; If (&RETCODE = %Attachment_Success) Then If &MESSAGE_LVL = 1 Then MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 27, "AddAttachment succeeded"); End-If; Else &ATTACHUSERFILE = ""; &ATTACHSYSFILENAME = ""; End-If; If (&RETCODE = %Attachment_Cancelled) Then If &MESSAGE_LVL = 1 Then MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 3, "AddAttachment cancelled"); End-If; End-If; If &MESSAGE_LVL = 1 Or &MESSAGE_LVL = 2 Then If (&RETCODE = %Attachment_Failed) Then MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 2, "AddAttachment failed"); End-If; If (&RETCODE = %Attachment_FileTransferFailed) Then MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 4, "AddAttachment failed: File Transfer did not succeed"); End-If; /* following error messsage only in iclient mode */ If (&RETCODE = %Attachment_NoDiskSpaceAppServ) Then MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 5, "AddAttachment failed: No disk space on the app server"); End-If; /* following error messsage only in iclient mode */ If (&RETCODE = %Attachment_NoDiskSpaceWebServ) Then MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 6, "AddAttachment failed: No disk space on the web server"); End-If; If (&RETCODE = %Attachment_FileExceedsMaxSize) Then MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 7, "AddAttachment failed: File exceeds the max size"); End-If; If (&RETCODE = %Attachment_DestSystNotFound) Then MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 8, "AddAttachment failed: Cannot locate destination system for ftp"); End-If; If (&RETCODE = %Attachment_DestSysFailedLogin) Then MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 9, "AddAttachment failed: Unable to login into destination system for ftp"); End-If; If (&RETCODE = %Attachment_FileNotFound) Then MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 29, "The file was not found so the operation could not be completed."); End-If; /* Error Message for Invalid file or No file name */ If (&RETCODE = %Attachment_NoFileName) Then MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 38, "AddAttachment failed: No File Name Specified."); End-If; End-If;