# DocAI with Custom Attachment Lists

**URL:** <https://forums.pega.com/t/docai-with-custom-attachment-lists/11855>\
**Category:** AI\
**Tags:** case-management, pega-platform\
**Created:** [May 3, 2026, 5:09pm UTC](https://forums.pega.com/t/docai-with-custom-attachment-lists/11855 "2026-05-03T17:09:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bodef](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/bodef/32/4598_2.png) [@bodef](https://forums.pega.com/u/bodef)\
**Post date:** [May 3, 2026, 5:09pm UTC](https://forums.pega.com/t/docai-with-custom-attachment-lists/11855/1 "2026-05-03T17:09:29Z")

</div>

**Video Walkthrough**

[https://players.brightcove.net/1900410236/4fVA8Ojzs\_default/index.html?videoId=6394493239112](https://players.brightcove.net/1900410236/4fVA8Ojzs_default/index.html?videoId=6394493239112)

Case management work often requires workers to review, cross-reference, and compare multiple documents before making a decision. Pega’s DocAI capability enables developers to build exactly this kind of experience: users can attach documents to a Pega case and an GenAI will automatically extract, compare, and summarise the key information across all of them.

The current configuration for specifying which attachments should be analyzed by a GenAI Connect rule is limited to specifying a single attachment property:

 ![image](https://pega1.discourse-cdn.com/pega/original/3X/8/a/8a0ae1f68e30d00de16a0c27879ec7ef7da44463.png)

This can obviously be a bit limiting.

Agents in Pega do a really good job of comparing and summarizing documents that a user uploads in the agent conversation

 ![image](https://pega1.discourse-cdn.com/pega/original/3X/b/4/b4b8444602048ed058d018d090b4faa9c788490d.png)

But it’s not obvious how this works. The agent tracer doesn’t show any tools being called for document analysis so what is happening here?

 ![image](https://pega1.discourse-cdn.com/pega/original/3X/8/9/899ad87daca10a21ce5d41333bcd94b05805a27a.png)

The attachments that the user uploads are stored as Data-WorkAttach-File-Temp objects and are referenced part of the Pega-Autopilot-Conversation work object. Every time the user asks the agent a question the attachment data for all of the uploaded documents is gathered up behind the scenes and included in the prompt that gets sent out to the LLM.

In order to be able to use a custom list of attachments in a GenAI Connect shape within a case I implemented a similar feature that can be used within the context of a case

**GetCaseAttachments Activity**

This activity replicates the functionality used in the OOTB Agent. It loops through D\_AttachmentList for the case and builds up a JSON representation of the attachments. I tried doing this with a Data Transform but there is no OOTB Data Page that I could find that returns the mime type for a Data-WorkAttach-File.

This could be based on a different attachment list that only retrieved a subset of the case attachments eg recently uploaded, specific attachment category or any other filtering mechanism.

 ![image](https://pega1.discourse-cdn.com/pega/original/3X/4/e/4e787509cf5e59708169cfdb1b15de48a8ec002c.png)

**D\_GetAttachmentData Data Page**

This is a basic wrapper for the GetCaseAttachments activity that will allow it to be easily called from a Declare Expression.

 ![image](https://pega1.discourse-cdn.com/pega/original/3X/b/9/b91ee6e6296e90e77d4755bed15ab02194ac804e.png)

**AttachmentData Property and Declare Expression**

This property is available at the Work- level and the declare expression allows it to be declaratively populated from any case.

 ![image](https://pega1.discourse-cdn.com/pega/original/3X/4/a/4af2613d03e17bf137680bf96bcfb976fcc6619d.png)

So in order to use it, we can just use the AttachmentData property in a GenAI Connect rule instead of checking the box to include attachments

 ![image](https://pega1.discourse-cdn.com/pega/original/3X/c/3/c313fd6407ad38cc5fc304839e47a8d57c7f1f29.png)

And at runtime we now get summaries and comparisons of custom attachment lists:

 ![image](https://pega1.discourse-cdn.com/pega/original/3X/3/2/32e15b8b1bb473abc5232c9b7949f0db8b46de2a.png)

**Possible Enhancements**

Run a Data Transform after the GenAI Connect to remove the contents of the AttachmentData property so that the document data is not duplicated in the case blob.

Customize the data page that returns the list of attachments to add filtering or provide the user with the ability to choose which attachments are included.

---

<div class="post-metadata">

**Author:** ![STEWJ](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/stewj/32/23281_2.png) [@STEWJ](https://forums.pega.com/u/STEWJ)\
**Post date:** [May 3, 2026, 11:37pm UTC](https://forums.pega.com/t/docai-with-custom-attachment-lists/11855/2 "2026-05-03T23:37:34Z")

</div>

Well done on this , we should definitely shoot for this to be out of the box configuraiton

---

<div class="post-metadata">

**Author:** ![sreenivasulur16806621](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/sreenivasulur16806621/32/20096_2.png) [@sreenivasulur16806621](https://forums.pega.com/u/sreenivasulur16806621)\
**Post date:** [May 4, 2026, 2:13am UTC](https://forums.pega.com/t/docai-with-custom-attachment-lists/11855/3 "2026-05-04T02:13:18Z")

</div>

well done.

---

<div class="post-metadata">

**Author:** ![PoojaPalla](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/poojapalla/32/12434_2.png) [@PoojaPalla](https://forums.pega.com/u/PoojaPalla)\
**Post date:** [May 5, 2026, 2:43am UTC](https://forums.pega.com/t/docai-with-custom-attachment-lists/11855/4 "2026-05-05T02:43:37Z")

</div>

Hey, this is super insightful 👏  
Had a quick question - since GenAI Connect already has the _‘Include attachments for analysis’_ option, is the main reason for overriding it just the limitation of supporting a single attachment property?  
Or does the custom approach give you more control over how multiple documents are passed and structured?

---

<div class="post-metadata">

**Author:** ![bodef](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/bodef/32/4598_2.png) [@bodef](https://forums.pega.com/u/bodef)\
**Post date:** [May 5, 2026, 3:29am UTC](https://forums.pega.com/t/docai-with-custom-attachment-lists/11855/5 "2026-05-05T03:29:21Z")

</div>

The way that this is set up, it’s just a workaround for not being able to control which documents are included in analysis.

---

<div class="post-metadata">

**Author:** ![garce](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/garce/32/23477_2.png) [@garce](https://forums.pega.com/u/garce)\
**Post date:** [May 13, 2026, 9:13pm UTC](https://forums.pega.com/t/docai-with-custom-attachment-lists/11855/6 "2026-05-13T21:13:17Z")

</div>

@bodef Well done. I appreciate you figuring this out and but sharing how we replicate it. Thank you.

---

<div class="post-metadata">

**Author:** ![Franz\_H](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/franz_h/32/23524_2.png) [@Franz\_H](https://forums.pega.com/u/Franz_H)\
**Post date:** [July 10, 2026, 12:10pm UTC](https://forums.pega.com/t/docai-with-custom-attachment-lists/11855/8 "2026-07-10T12:10:55Z")

</div>

This is really cool stuff, thank you Fergal!

I tried to replicate this, however the JSON that gets ingested into the GenAI Connect rule via .AttachmentData doesn’t get decoded properly and seemingly is just interpreted as text data by the LLM (I use Sonnet 4.6; tried it with png, jpg, and pdf files).

Here’s how it looks on my end:

`{"attachments":[{`  
`"pxApplication":"X",`  
`,"pxAttachedBy":"x.y@z.com"`  
`,"pxAttachedByOrganization":"MyOrg"`  
`,"pxAttachedByOrgDivision":"Div"`  
`,"pxAttachedByOrgUnit":"Unit"`  
`,"pxAttachedByWorkgroup":"default@MyOrg"`  
`,"pxAttachKey":"2026-07-09T14:06:02.931Z"`  
`,"pxAttachName":"sample.png"`  
`,"pxCommitDateTime":"2026-07-09T14:06:02.949Z"`  
`,"pxCreateDateTime":"2026-07-09T14:06:02.930Z"`  
`,"pxCreateOperator":"x.y@z.com"`  
`,"pxCreateOpName":"X Y"`  
`,"pxCreateSystemID":"pega"`  
`,"pxInsName":"MYORG-X-WORK E-3016!20260709T140602.931 GMT"`  
`,"pxObjClass":"Data-WorkAttach-File"`  
`,"pxRefObjectKey":"MYORG-X-WORK E-3016"`  
`,"pxSaveDateTime":"2026-07-09T14:06:02.931Z"`  
`,"pyAttachMimeType":"image/png",`  
`,"pyAttachStream":"data:image/png;base64,iVBORw0KGgoAAAA...`  
`,"pyCategory":"File"`  
`,"pyNote":"sample.png"`  
`,"pzInsKey":"DATA-WORKATTACH-FILE MYORG-X-WORK E-3016!20260709T140602.931 GMT"`  
`}`  
`]}`

Maybe I did something wrong? It would be amazing if you could give some input - much appreciated!

---

<div class="post-metadata">

**Author:** ![bodef](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/bodef/32/4598_2.png) [@bodef](https://forums.pega.com/u/bodef)\
**Post date:** [July 15, 2026, 3:15pm UTC](https://forums.pega.com/t/docai-with-custom-attachment-lists/11855/9 "2026-07-15T15:15:01Z")

</div>

Hi Franz, this is how the attachment data for each document is constructed:

AttachmentPage is a Data-WorkAttach-File object

AttachmentPage.pyAttachMimeType: @contains(AttachmentPage.pyAttachMimeType,“application/vnd.openxmlformats-officedocument.wordprocessingml.document”) ? “application/docx” : AttachmentPage.pyAttachMimeType

AttachmentPage.pyAttachStream: “data:”+AttachmentPage.pyAttachMimeType+“;base64,”+AttachmentPage.pyAttachStream

Document Data for JSON: Primary.AttachmentDataTemp + “{“name”:”" + AttachmentPage.pxAttachName + “”,“detail”:“log”,“mimetype”:“” + AttachmentPage.pyAttachMimeType + “”,“content”:“” + AttachmentPage.pyAttachStream + “”}, "

So basically the JSON has to be built up based on the content of the Data-WorkAttach-File object for each attachment. I can share a ruleset with you if you like that has the working implementation (9 rules in total) Drop me an email [first.last@pega.com](mailto:first.last@pega.com) if you like.

---

<div class="post-metadata">

**Author:** ![Arunkumar\_Velmurugan](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@Arunkumar\_Velmurugan](https://forums.pega.com/u/Arunkumar_Velmurugan)\
**Post date:** [September 23, 2026, 10:09am UTC](https://forums.pega.com/t/docai-with-custom-attachment-lists/11855/10 "2026-09-23T10:09:20Z")

</div>

Thank you for sharing this. This is very insightful.  
We can further extend this feature by retrieving the outcomes from the GenAI Connect response and displaying them as individual list values.

Additionally, we can present a comparison using Pega DX “CompareTableLayout” component from the component gallery to provide a side-by-side comparison view. This would make it much easier for end users to evaluate the results and identify differences effectively.
