Question
Barclays
IN
Last activity: 30 Aug 2023 9:34 EDT
Store attachment to Pega database or Repository on conditional basis
I have a requirement that while attaching any file to case, I will be capturing type of file. For certain file type it should be stored in Pega database and for others it should go in one repository. I have selected default Pega database in Application rule so first problem is solved. For second scenario I need to use repository API as well as extract data in stream and use pyStream since file size is going to be huge. Also I am not able to store file in repository as Pega throws error that it fails to create file when I try to use string in pyContents.
I need to stick to keep default storage as Pega database keeping in mind in other scenarios in application. Repository connections are perfect and when I test by setting Repository as default storage, files are getting saved. It is manual API which is getting failed.
@Girish Gaikwad To achieve this requirement, you can use the Pega repository APIs to store specific file types in the repository while keeping the default storage as the Pega database.
First, ensure that the repository is correctly configured and working when set as the default storage.
When using the repository APIs, make sure you are using the correct data type for the file content. Since the file size is going to be large, you should use the pyStream property to handle the file content.When using the D_pxSaveFile API, set the pyContents property to the pyStream value.
If you still encounter issues with the API, check for any unsupported characters in the file name, as they might cause errors. Also, ensure that your access group has the PegaRULES:RepositoryUser role to use the repository APIs.
Remember that when using the repository APIs, the file content is loaded into memory as a base-64 encoded string. If the file size is larger than the maximum allowed size (default is 45 MB), an exception is thrown. You can configure the maximum file size using the repository/maxFileSizeInMemory dynamic system setting in the Pega-IntegrationEngine ruleset.
This answer came from a Pega gen-AI assistant using the below references. As a Support Center moderator, I reviewed the answer and references for accuracy:
@Girish Gaikwad To achieve this requirement, you can use the Pega repository APIs to store specific file types in the repository while keeping the default storage as the Pega database.
First, ensure that the repository is correctly configured and working when set as the default storage.
When using the repository APIs, make sure you are using the correct data type for the file content. Since the file size is going to be large, you should use the pyStream property to handle the file content.When using the D_pxSaveFile API, set the pyContents property to the pyStream value.
If you still encounter issues with the API, check for any unsupported characters in the file name, as they might cause errors. Also, ensure that your access group has the PegaRULES:RepositoryUser role to use the repository APIs.
Remember that when using the repository APIs, the file content is loaded into memory as a base-64 encoded string. If the file size is larger than the maximum allowed size (default is 45 MB), an exception is thrown. You can configure the maximum file size using the repository/maxFileSizeInMemory dynamic system setting in the Pega-IntegrationEngine ruleset.
This answer came from a Pega gen-AI assistant using the below references. As a Support Center moderator, I reviewed the answer and references for accuracy:
Creating a repository
Using repository APIs in your application > Repository notes and considerations { .section}
Storing case attachments using external storage
If you still encounter errors in the log please log a support incident on the MSP and provide the INC id here for us to help track.