cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to get the actual attachment name from Outbound proxy to CPI

sugata_bagchi2
Active Contributor
0 Kudos
476

Hi Everyone ,
I am trying to capture the attachment names in SAP CPI, from an outbound proxy call from SAP- but I am only getting the attachment ID as name and not the actual attachment name.
I am using the below line in my Groovy - message.setProperty("attachmentName",attachment.getName());
where attachment is a DataHandler object.
In proxy, I have the below name of the attachments -

sugata_bagchi2_0-1727650402327.jpeg

but in CPI I am getting the attachment name as -payload-000D3A03E1FD1EDF9FC56D07DA1F65E6@sap.com

Could you please help me with this to get the actual attachment name?

Thanks

Sugata

Accepted Solutions (0)

Answers (1)

Answers (1)

ShaikAzmathulla
Active Participant
0 Kudos

Hi ,

Please try with this : 

message.setProperty("attachmentName", attachment.getDataSource().getName());

def attachment = message.getProperty("yourAttachmentProperty") --> Replace with your actual attachment property name
def attachmentName = attachment.getDataSource().getName() --> This should fetch the correct attachment name
message.setProperty("attachmentName", attachmentName)

Regards , 

 

 

sugata_bagchi2
Active Contributor
0 Kudos
@ShaikAzmathulla - thank you for your reply. Could you please check if the below one is the correct ?
sugata_bagchi2
Active Contributor
0 Kudos
def Message setAttachmentProperty(Message message) { // Create a new Map of attachments and store it in a property. def attachments = new HashMap<String, DataHandler>(message.getAttachments()); Iterator<DataHandler> it = attachments.values().iterator(); DataHandler attachment = it.next(); //message.setProperty("attachmentName", attachment.getName()); message.setProperty("attachmentName", attachment.getDataSource().getName()); message.setProperty('Attachments', attachments); // Store the number of attachments in a property. message.setProperty('AttachmentCount', attachments.size()); // Clear the attachments and attachment wrappers. message.getAttachments().clear(); message.getAttachmentWrapperObjects().clear(); return message; }