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

 

 

Forteen Stars

Re: SalesForce : Attach pdf with component tSalesForceOutput

@jblot,check the below link for the example.

https://corycowgill.blogspot.com/2013/06/inserting-pdf-attachments-into.html

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Highlighted
Fifteen Stars TRF
Fifteen Stars

Re: SalesForce : Attach pdf with component tSalesForceOutput

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

 


TRF
Fifteen Stars TRF
Fifteen 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

 

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch