Search This Blog

Showing posts with label Peoplecode Add Attachment. Show all posts
Showing posts with label Peoplecode Add Attachment. Show all posts

Tuesday, January 24, 2012

Preserve case parameter in addattachment function

Below post is helpful to those who have encountered an issue with the file extension getting converted to lower case  instead of retain the same.

We use add_attachment(list_of_param....) to upload files to the server.
Inside the Add_attachment(list_of_param....) function there is a builtin library function addattachment(list_of_param....) which actually uploads the file in the server.

There is one parameter called preserve case which helps to retain the extension which user had uploaded.
By default, it is set to false.
That means if user uploaded "Test_File.TXT" , the file name on the server will be "Test_File.txt".

There could some cases where you feel the extension of the file should not change.
In that case , change the value to 'true'.

AddAttachment(URLDestination, DirAndFilename, FileType, UserFile[, MaxSize]                                                                     [, PreserveCase, UploadPageTitle])

Above syntax is from tools version 8.49


Monday, October 31, 2011

Add Attachment

Uploading files through Add button at level0 and showing the uploaded files onto a grid.
Main records:
Transaction Record at Level 0 : PS_REC_TRANS.
Transaction Record at Level 1: PS_REC_UPLD
Derived Work Record: FILE_ATTACH_WRK or custom record which is clone of the FILE_ATTACH_WRK

Details:
-->Suppose that we have a transaction record PS_REC_TRANS and TRANS_KEY is a Key.
-->Since we are showing uploaded files in the grid, the level1 record (PS_REC_UPLD) should have 2 keys (TRANS_KEY and ATTACHSYSUSERFILE).
-->Now we need to have a derived work record that holds the buttons 'Add Attachment/Delete Attachment/View Attachment'.
There is a delivered record (FILE_ATTACH_WRK) but PeopleSoft recommends to use own custom record which is a copy of delivered record. This recommendation is made so that in future if any changes are done it should not impact the current functionality.

Designing the page:
Add PS_REC_TRANS at level0.
Drag and drop the AddAttachment button onto the page. (level 0).
Optional: Mostly we would like to see the uploaded file next to AddAttachmet button. To accomplish this create a derived work record that holds the ATTACHUSERFILE field.
Insert grid.
Drag and drop the record PS_REC_UPLD onto the grid.
Also include the buttons Delete Attachment and View Attachment onto the grid.
Save the Page.
We need to add peopleocode to the buttons to implement the attachment functionality.
Better if we use Component record field peoplecode, as it will not impact any other comoponent.
Now consider the 'Add Attachment ' Button. Once the user clicks on this button file should be uploaded to the server and then after successful upload filename should appear in the level1 grid.
To make this happen, Declare the function Add_attachment and then call the function. There will be a status field present in the function which will let us know the attachment if failure / success.
Call the level1 rowset and insert the file data. Make sure that DoSave() method to be called.
I will be providing the code in the next post.