Giving PeopleSoft users the ability to upload files from a page by using the infamous "Browse" button is something that you will most likely do at one point in your PeopleSoft career. As a matter of fact, some questions are popping up on the forum asking for a sample code to get the above requirement accomplished.
I will not be giving any sample code in this post BUT I will show you the way to find the code. Code that is delivered by PeopleSoft and does a little bit more that just uploading a file! The code will show you how to View and Delete uploaded files as well.
Just navigate to PeopleTools > Utilities > Debug > PeopleTools Test Utilities to get the component and page name (Ctrl+J). Open Application Designer and start looking at the code. That same code could be used on your own custom page to allow users to upload, view and delete attachments!
The PeopleTools Test Utilities page is also used to test for Java calls. This is outside the topic of this post, the only section that matters for us on the page is the "File Attachment Test".

| Title | Under | Posted on |
|---|---|---|
| How to run nvision report through portal | PeopleSoft Technical | 08/31/2010 - 4:45am |
| Any1 here who can help? | PeopleSoft Technical | 08/31/2010 - 2:12am |
| How to create matrix layout | PeopleSoft Technical | 08/27/2010 - 2:22am |
| UnCaught C++ Exception | PeopleSoft Technical | 08/10/2010 - 9:05am |
Comments
I have Troubles with this page i opened the "File Attachment Test page but none of the buttons has any peoplecode i tried placing one buttons just like those and didn't work.
Can you help me more please
You can try out this Code:
Write the code in FieldChange event:
Component string &FileUploaded;
Local string &UPDATE = "Y";
SQLExec("SELECT ATTACHSYSFILENAME FROM %table(CSGC_CSHT_ATACH) WHERE LASTUPDOPRID = :1", %OperatorId, &OldFileName); /* Get the previous file name */
&RETCODE = AddAttachment("RECORD://CSGC_CSHT_ATACH", &ATTACHSYSFILENAME, "", &ATTACHUSERFILE, 0);
Evaluate &RETCODE
When = 0 /* Returns Zero, when user clicks on OK with the valid File Path */
/* Then Check whether the file is only .txt file or not, if not throw an error msg and delete the file */
If Lower(Right(&ATTACHUSERFILE, 4)) <> ".txt" Then
MessageBox(0, "", 27333, 44, ""); /* You can only upload .txt files. */
&RETCODE1 = DeleteAttachment("RECORD://CSGC_CSHT_ATACH", &ATTACHUSERFILE); /* Delete file */
&FileUploaded = "N";
&UPDATE = "N";
End-If;
SQLExec("SELECT COUNT(1) FROM %table(CSGC_CSHT_ATACH) WHERE LASTUPDOPRID = :1", %OperatorId, &Count); /* Check whether any rows are there in Attachment Record or not */
If &Count > 1 Then /* means more than one record is existing, So Delete the previous file */
&RETCODE2 = DeleteAttachment("RECORD://CSGC_CSHT_ATACH", &OldFileName); /* Delete file */
End-If;
If &UPDATE = "Y" Then
&UpdatedFileName = %OperatorId | "_" | &ATTACHUSERFILE;
SQLExec("UPDATE %table(CSGC_CSHT_ATACH) SET ATTACHSYSFILENAME = :1 WHERE LASTUPDOPRID = :2", &UpdatedFileName, %OperatorId);
&FileUploaded = "Y";
End-If;
Break;
When = 11 /* Returns 11, when user clicks on OK without File Path */
When = 2 /* Returns 2, when user clicks on CANCEL Button */
MessageBox(0, "", 27333, 67, ""); /* Please Specify the path and upload again. */
&FileUploaded = "N";
Break;
End-Evaluate;
I am getting the below error while attaching a file. Please help.
CAN NOT LOCATE DESTINATION SYSTEM
Post new comment