I have a requirement to upload a certain file and attach it to a work object. The file is going to be a jar file that I will parse to extract an xml file from. I am interested in attaching and showing the xml file and not the jar file.
Later on, the user should be able to download that XML file when they click on a button/link.
I've been experimenting around with some OOTB functionalities, such as the AttachContent control, and DisplayAttachFile activity, but I haven't been successful. The AttachContent control works as expected, but it doesn't really fulfill my requirements. The activity on the other hand does nothing; I have a button configured to call the activity on click, and I’m even hardcoding the parameters but nothing happens (the activity is getting called alright but the file is not being downloaded). I also tried calling the Work- GetAttachmentReference activity (which is what gets called by the system when you try to download an attachment from the Right Pane of the portal), also with hardcoded parameters, and still no go.
The work object can have multiple attachments, but I only want to display the XML files in a grid (a repeating grid or repeating section are what came to my mind). I thought of saving the attachment as a Java Object property of the instance of the work object, but I haven’t found any way of how to do so.
I would appreciate any solution/suggestion that might help me implement that.
Let me know if I can provide any additional information to make the requirements or issue clearer.
***Updated by Moderator: Vidyaranjan | Included Categories***
I don't have a detailed answer here ; but just some thoughts that might help with the discussion here.
So to me ; it looks like you have broadly 3main requirements here; you to do the following:
1. A way to allow uploading of a JAR file to PRPC; and to 'intercept' that upload and get hold of the contents of the JAR.
2. A way of processing a JAR file, and extracting out an XML file from that JAR. (An XML file with a specific name/path presumably; or does it have to 'walk' through the JAR to find it etc. ?).
3. A way of attaching an XML file to an existing PRPC Work Object.
For 1: If a 'BATCH' type mechanism is OK - rather than say a User Uploading a File From their Browser - you use a PRPC File Listener to do this. If you need Users to Upload a File in the Browser; I'm not quite sure on the best way of doing that (But you could use a PRPC Tracer and/or a Fiddler (etc) to Trace what happens when an attachment is uploaded to PRPC for instance ?)
For 2: If you use a File Listener ; then writing a PRPC Activity to process a JAR (a 'zip' file) should be do-able using Java Steps.
For 3: you should be able to use an OOTB 'AttachToWork' Activity to attach the XML (base64encoded,probably).
For (sort-of) the opposite of what you are asking here: take a look at this previous POST - this was a question on how ZIP-UP a file and attach to PRPC ; I suspect there will be a lot in common between this and your requirement.
Sorry for the delayed reply (still not getting notifications when someone replies).
Please find below my replies:
The requirement is for the user to use their browser yes. I have been able to use the OOTB control to attach the file to the work object.
I was thinking along the same lines as you here; I haven’t been able to attempt to tackle this issue because I’m still blocked by the other shortcomings. Even if I use the default Pega AttachContent control, I am still able to browse the object, so I believe I should be able to use a Java step to parse it (the xml file is of a specific name).
My main issue is with downloading the file. I tried to use the OOTB activities that Pega uses but I was unsuccessful, even though the tracer is almost identical. I am still trying to get the DisplayAttachFile activity to work, as it is called by Pega when you want to download attachments (same goes for the GetAttachmentReference).
I don’t know if anyone has had experience with these 2 activities or would know why they are not functioning properly, but this is definitely something that I need to overcome.
Thank you as well for the link. I will go through that thread to see if it can be of any help.