Discussion

Euroclear
Euroclear
BE
Euroclear
Posted: Oct 15, 2024
Last activity: Oct 15, 2024
Last activity: 15 Oct 2024 11:50 EDT
How to use PEGA File API ( D_pxNewFile ) to upload Case attachments in PEGA Directory
You might have come across the requirement wherein you may need to upload PEGA case attachments to specific directory on your PEGA server. There are two ways this can be done:
- Using traditional Connect-File method which is Deprecated/
- Using File APIs
Here I am going to explain how we can leverage PEGA's File API data pages to upload case attachments to any specific directory on PEGA server. Below are the steps:
- Any user who attaches the documents to PEGA case those attachments becomes the part of OOTB page list ( pyCaseRelatedContent ) which is inside top level pyWorkPage as below:
- Idea is to extract the attachment data from this pagelist. How we do it ? Just loop on this page list in the context of your Work page and extract the key .pxLinkedRefTo you assign this key to one parameter of your choice.
- After you have the key try to open the attachment on Page of class ( Data-WorkAttach-File ) please refer below snap
- Once the Attachment data is fetched on "WorkAttach" as mentioned above next step is to get the attachment stream or file byte code in a parameter please refer below:
- Additionally you need two more parameters which are repositoryName and filePath. ( RepositoryName is nothing but a repository instance which you have to create connecting to Parent directory on your server and second is the filePath which is the exact path including filename and extension of the file for e.g. fileabc.csv )
- Next step is to initiate or load datapage and set the attach stream to data page b( D_pxNewFile[repositoryName:Param.repositoryName,filePath:Param.filePath]) see below:
- After the contents are loaded next step is to save the data page :
- After above steps are performed how to confirm that content are written or file is placed at destination you can run OOTB D_pxListFiles by passing Repository name and Folderpath don't forget to flush instances before you run the data page.