Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
jblot
Contributor
Contributor

SalesForce : Attach pdf with component tSalesForceOutput

Hi all,

 

I want to attach pdf file into SalesForce.

I use the tSalesForceOutput with module Name : ContentVersion

I put the fields : TITLE / DESCRIPTION / PathOnClient / VersionData (as with DataLoader SF).

 

My job is running successfully but my pdf file in SalesForce is empty.

My job in attachment.

I'm in Talend 7.0.1

 

Any idea?

Jérémy

 

 

Labels (3)
5 Replies
manodwhb
Champion II
Champion II

TRF
Champion II
Champion II

At least, the document must be Base64 converted to populate the VersionData field.

 

TRF
Champion II
Champion II

@manodwhb, ContentVersion is not the same as Attachment

jblot
Contributor
Contributor
Author

Hi,

 

Thank you for your response.

I try to convert my field but I have the same problem : my pdf is empty in SalesForce.

 

This is my tMap : 

0683p000009M1AZ.png

I attach my job


AG_EXPORT_MONTHLY_REPORT.zip
jblot
Contributor
Contributor
Author

Hi all,

 

Finally, I resolve my problem with this code :

File file = new File((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"));

try {

FileInputStream documentInFile = new FileInputStream(file);
byte[] documentData = new byte[(int)file.length()];
documentInFile.read(documentData);
output_row.Body = new String(Base64.encodeBase64(documentData));

} catch (FileNotFoundException e) {
output_row.conversionCode = "FILE_NOT_FOUND";
output_row.conversionMessage = "File not found "+(String)globalMap.get("tFileList_1_CURRENT_FILEPATH");
System.out.println("*** File not found "+(String)globalMap.get("tFileList_1_CURRENT_FILEPATH")+"\n"+e);
} catch (IOException ioe) {
output_row.conversionCode = "CONVERSION_ERROR";
output_row.conversionMessage = "Error converting file "+(String)globalMap.get("tFileList_1_CURRENT_FILEPATH");
System.out.println("*** Error converting file "+(String)globalMap.get("tFileList_1_CURRENT_FILEPATH")+"\n"+ioe);
}

 

I put this result in field VersionData on the ContentVersion module name

 

Jérémy