Symptom
You are trying to retrieve all the email's attachments from Tickets using custom logic to access the Association AttachmentFolder on ServiceRequest BO, but you are only able to retrieve the first attachment added to the Ticket.
Environment
SAP Hybris Cloud for Customer - All it' versions
SAP Cloud Applications Studio - All it's versions
Cause
You tried to access the attachment searching it with following path BO: Service Request -> Association: EmailActivityReference -> Association: EmailActivity -> Association: AttachmentFolder -> Association: DocumentList, but this path will only contain the first attachment added on the email related to the Ticket. The Service Request in this case, is associated only to the first email via reference. Any subsequent email chain that happens uses the first Email UUID as InitiatingActivityUUID and no reference back to Service request is maintained.
Resolution
1. Get the main email UUID using the reference of service request (BO: ServiceRequest -> Assotiation: EmailActivityRef -> Element: UUID)
2. Query for the Activity Record(s) linked to the Ticket using the UUID retrived from the Step #1 (BO: Activity -> Query: QueryByElements -> Element: InitiatingActivityUUID). This would return all the emails which are related to the ticket (if you are interested only in inbound emails you can further provide direction in query parameters)
3. For each entry in the result, fetch the Association AttachementFolder to get all the attachments of that particular Ticket (BO: Activity -> Association: AttachmentFolder -> Association: DocumentList)
Keywords
Ticket; Email; Attachment; AttachmentFolder; DocumentList; InitiatingActivityUUID; ServiceRequest; Activity; , KBA , AP-RC-BDS-SCR , ByDesign Studio Scripting (ABSL) , How To