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 |
---|---|---|
Component interface Error: no rows exist for the specified keys | PeopleSoft Technical | 03/15/2019 - 3:54am |
ADD 24 months starting from current month.(peoplesoft) | PeopleSoft Functional | 07/29/2018 - 8:44pm |
TRC values dropdown | PeopleSoft Technical | 04/04/2018 - 12:54am |
how to find missing sequence in GRID and print the mising sequence number while saving through peoplecode | PeopleSoft Technical | 09/11/2017 - 4:49am |
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;
Raj
I am getting the below error while attaching a file. Please help.
CAN NOT LOCATE DESTINATION SYSTEM
Hello everyone,
I am, able to add the attachment from the below code but am not able to view the file ... can anyone suggest me on this....
Declare Function add_attachment PeopleCode FILE_ATTACH_WRK.ATTACHADD FieldChange;
Declare Function display_attachment_buttons PeopleCode FILE_ATTACH_WRK.ATTACHADD RowInit;
Local number &CurRow, &RETCODE;
Local string &Guid, &URL_ID;
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Call the correct database record where your file attachment */
/* will be stored */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
&URL_ID = "URL.N_LOCATION_TBL";
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* In order to make sure the attachmentname is unique */
/* you can add a GUID in front of your File name */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
&Guid = UuidGenBase64();
add_attachment(@&URL_ID, "", &Guid, 0, True, "Record.N_LOCATION_TBL", N_LOCATION_TBL.ATTACHSYSFILENAME, N_LOCATION_TBL.ATTACHUSERFILE, 2, &RETCODE);
WinMessage("&RETCODE" | &RETCODE, 0);
If &RETCODE = %Attachment_Success Then
display_attachment_buttons(N_LOCATION_TBL.ATTACHUSERFILE);
WinMessage("Attachment Uploaded");
DoSaveNow();
End-If;
You need to use ViewAttachment function to view the uploaded file.
Regards,
Hari.A
Hello,
Can you please help me to solve this error when adding attachment in the page? The below error is prompting when I am attempting to attach the file. Thanks!
"AddAttachment failed (137,2)
The AddAttachment() call failed. "
CODE:
Declare Function add_attachment PeopleCode FILE_ATTACH_WRK.ATTACHADD FieldChange;
Declare Function display_attachment_buttons PeopleCode FILE_ATTACH_WRK.ATTACHADD RowInit;
Local number &CurRow, &RETCODE;
Local string &Guid, &URL_ID;
&URL_ID = "URL.RECEIPTS";
&Guid = UuidGenBase64();
add_attachment(@&URL_ID, "", &Guid, 0, True, "Record.CSAA_EX_ATTACH", CSAA_EX_ATTACH.ATTACHSYSFILENAME, CSAA_EX_ATTACH.ATTACHUSERFILE, 2, &RETCODE);
If &RETCODE = %Attachment_Success Then
display_attachment_buttons(CSAA_EX_ATTACH.ATTACHUSERFILE);
DoSaveNow();
End-If;
Helo,
How can attchment be blank evrytime that the user is activating the page again to create attachment? The history attached file by the user is still there. Thanks!
This is now workking. I already solved the error.
How did you resolve the error?
Can you please share, since this forum works best when we all exchange solutions and ideas.
Thanks!
Does anyone know of a way to allow a user to upload an image file and also capture the file, rename it and move it to shared directory? I can accomplish it by using the InsertImage(), AddAttachment() and PutAttachment() functions, but it requires the user to 'upload' the file twice. We're trying to allow a third party application to view the uploaded images which are stored in the INV_ITEM_PHOTO record, by sending the application a full url path to the item image file in a shared directory.
I have out in the component PostBuild event a scrollflush function.
i am looking for a code that can check the originality of the file (that means if the file is renamed , then it should not be allowed to be uploaded in a browser)
if any one could suggest ...
Hello,
I was able to apply this code to send an attachment to our server, and also to retrieve (view) a file. But something is happening to the files when I return them from the server to view them. For example, I tried to save a text file, but when I view the file it appears that all the carriage returns have been removed. A file saved like this:
-- Script : delete_bad_referral.sql
--
-- 01/10/2011 rjm
--
-- Return failure code when program does not complete successfully
whenever sqlerror exit failure;
whenever oserror exit failure;
Comes back looking like this:
-- Script : delete_bad_referral.sql -- -- 01/10/2011 rjm -- -- Return failure code when program does not complete successfully whenever sqlerror exit failure; whenever oserror exit failure; set echo on set feedback on set head off set linesize 500 --select select * FROM sysadm
Has anyone seen this before? Know how to correct it?
Hi All,
I am facing the issue with file upload.
we have two
either we can you URL.yourURL ID or FTP://YourFTPUser:YourFTPPassword@YourComputerName/YourDirectoryPath
when i am using the URL.yourURL then files is uploaded sucessfully. but when i am using the FTP command then it's not working . i want both the option to be work .can somebody help me here
Hi All,
Need to upload some files to https location using AddAttachment function. I created a URL definition for that https path and used that in Addattachment function. But it is throwing the following error during uploading of files.
AddAttachment() call failed.
Message not found
please help
The AddAttachment function limits the user to files with names no longer than 64 characters long. I have a user thatinsists they must use longer file names when uploading the file into our system. Unfortunately, there is no way to reconfigure the AddAttachment parameters to allow for a longer file name. How can I just display the same windows open file dialog pop-up dialog (as is displayed using AddAttachment) and then manipulate the file behind the scenes? Or can I trick the AddAttachment to return the file name even if it is too long?
Look like there are no ways to manipulate that unfortunately as that was the way PeopleSoft has written the function, and we cannot extend that (like other languages). The only thing you can do is display a text on the page and let users to upload a file which has max 64 chars in the file name
you can also use the method described in here to restrict the file types;
http://peoplesoftdotnet.blogspot.com.au/2015/03/restrict-filetypes-peoplecode-2.html
http://peoplesoftdotnet.blogspot.com.au/2015/02/how-to-restrict-file-types-extensions.html
I am getting error Add attachment failed 137,2. When I looked at trace log, it shows "failed to get table name for record PS_ENRL_FILE". I created this custom record to store the attached files by using sub record FILE_ATTDET_SBR.
Interesting this is If I use delivered record to PSFILE_ATTDET to store file it works...
Please help.
Can you let us know how you solved this error please?
When I open a file with viewattachment then file is displaying in new browser window. In New browser window, back button is displaying in the browser. When i Click on that button, system is showing '404 not found' error.
Is there any way to hide/disable back button on the browser when file opens in the browser .
Dude,
Check in View Record PeopleCode... You will get...