6. Delete API [ D-pxDelete ]
Goal:
Create an activity that deletes a file or folder that you specified.
For D_pxDelete API, pass in the following parameters:
Before Pega configuration, make sure you have a file in repository. In this example, I have "Pega Infinity_A-2002.png" in root path.
1. Create an activity as below. First of all, add an new entry to Pages & Classes. Add "D_pxGetFile" in Page name, and add "Embed-Repository-File" in Class.
In the Step 1, I am setting required parameters for D_pxDelete API.
2. recursiveDelete doesn't matter when you are trying to delete a file. So it can be true or false. If you are trying to delete a folder, this parameter matters (I will explain later).
3. Either way, I recommend that you set it to true regardless.
4. In the Step 2, I am deleting the file using API. D_pxDelete[repositoryName:Param.repositoryName,filePath:Param.filePath,recursiveDelete:Param.recursiveDelete].
I am only specifying it in Step Page but you can also use Load-DataPage method.
5. Run this activity from Dev Studio. Make sure the file is deleted from repository successfully. And Clipboard also you can output whether it is deleted or not.
Notes:
If you are trying to delete a folder instead of a file, you can, but in that case, you must meet either of conditions below to succeed:
1. The folder must be empty.
2. The recursiveDelete parameter must be true.
That means, if you set recursiveDelete parameter to true, system always delete it anyways and there is no issue. This is the recommended approach.
If, the parameter is set to false, and the folder contains files or folders, error is thrown in log files.
0 Comments