How to restrict FileTypes (extensions) from URL Object Properties When Adding Attachments Part II

So, as I mentioned in  How to restrict File Types (extensions) from URL Object Properties When Adding Attachments Part I post, I have tested this particular configuration when adding attachments.
The good news is it worked :-)
So, how did it exactly work?
Well, assuming that you have configured a File Extension list and added a list of accepted or rejected file types to that list as per my previous post. Once done you are ready to go and check whether it is working.
As per AddAttachment PeopleCode function, once the file is uploaded you can check the return code which is either an integer or a constant value. Then you can check the return code "21" which is to check the File Extension from the File Extension list that you have configured.

So basically you can try out a code similar to,
/*check the Return code for file extension validation*/
/*Retrun code 21 - "File transfer failed because the file extension is not allowed*/
&RETCODE = AddAttachment("URL.MYTESTRECORD", &ATTACHSYSFILENAME, "", &ATTACHUSERFILE, 0);
   If &RETCODE = 21 Then
      Error MsgGet(12345, 5, "File transfer failed because the file extension is not allowed");
Else
/*Do something*/
End-if;
SHARE

Ayesha Wee

    Blogger Comment
    Facebook Comment

0 comments :

Post a comment