Share all details related to your problem, including any error messages you may have received.
Has anyone come across a requirement to read the file attachments added in the access request and then append the file attachment into the approval email?
I know the attachment in the request are represented in the AttachmentDTO tags. I m kind of unsure if the attachment can be directly read and passed as an argument to the email template or needs to be reconstructed by reading the file name and the byte array of its content.
I have got a sample code from the community as below:
List attachment=accRequest.getArgument("attachments");
AttachmentDTO attDTO = attachment.get(0);
Attachment attch=context.getObjectByName(Attachment.class, attDTO.getName());
With the change I am able to read the attachment and append it into the email. Only one issue I have is that when I open and check the content of the file, it seems kind of encoded values as below:
Just for the testing have you validated the data being returned from the above line is have some proper details.
Also, which file type you are attaching at present and then reading?
Yep the statement above return the attachment information as below:
The testAttachment.txt file is a sample file that includes dummy sentences as below:
When i open the attachment from the email, the sample file content seems encoded as follows: 2:ACP:3Nwo68lnDwfBVxjSVdSuraXvW2KiGI7aqGiZsHuCfZ86hw0+oRENnWgVLU4u9A9pXDS/fbhuf4Hd uEPLQcxX1w==
Ty Vishal… i checked with the decrypt method of the following encrypted string: 2:ACP:3Nwo68lnDwfBVxjSVdSuraXvW2KiGI7aqGiZsHuCfZ86hw0+oRENnWgVLU4u9A9pXDS/fbhuf4Hd uEPLQcxX1w==
but the return is not the correct content present in the file: