Upload Files in PeopleSoft (File Attachment)

Your rating: None Average: 4 (3 votes)

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".

/files/peoplesoft-test-utilities-page.png

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!

Comments

Have a question? Please ask it on the forum instead.
Guest's picture
Guest (not verified)
Re: Upload Files in PeopleSoft (File Attachment)

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

raj.psoft's picture
User offline. Last seen 16 weeks 3 days ago. Offline
Joined: 03/25/2010
Posts: 5
Re: Upload Files in PeopleSoft (File Attachment)

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;

pramod's picture
pramod (not verified)
Re: Upload Files in PeopleSoft (File Attachment)

I am getting the below error while attaching a file. Please help.

CAN NOT LOCATE DESTINATION SYSTEM

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
The question below is to prevent automated spam submissions.
3 + 10 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Unanswered Forum Posts