SalesForce : Attach pdf with component tSalesForceOutput

Five Stars

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

 

 

Thirteen Stars

Re: SalesForce : Attach pdf with component tSalesForceOutput

Highlighted
Forteen Stars TRF
Forteen Stars

Re: SalesForce : Attach pdf with component tSalesForceOutput

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

 


TRF
Forteen Stars TRF
Forteen Stars

Re: SalesForce : Attach pdf with component tSalesForceOutput

@manodwhb, ContentVersion is not the same as Attachment


TRF
Five Stars

Re: SalesForce : Attach pdf with component tSalesForceOutput

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 : 

image.png

I attach my job

Five Stars

Re: SalesForce : Attach pdf with component tSalesForceOutput

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

 

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.