
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Convert String to base64
Hi. Im kind of newbie in all these things and definitely cannot code, so please be patient with me In our Salesforce org we have custom Note field (String) on Account object. There is a new Notes feature (introduced few releases back), information is stored in ContentNote object, in the Content field, which is base64 type. Im trying to migrate old Notes in new Notes. Im facing the problem to convert the data from String to base64. I found the article where was recommended to use tJava component with following code:
String s = new sun.misc.BASE64Encoder().encode(out.Content); //System.out.println("Text Decryted : " + s); row4.Content = s;
I tried this but unfortunately it doesnt work, I received an error saying:
Error in the component's properties:The method encode(byte[]) in the type CharacterEncoder is not applicable for the arguments (String)
Can anyone please help? See attached pictures. For this moment Im just trying to create records in new Notes, I will relate them to Accounts in next step. Many thanks for help
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think you need to convert String to bytes array before to encode.
Here is a example from StackExchange for the conversion:
String example = "Convert Java String"; byte[] bytes = example.getBytes();
You need to put this in the tJava (or tJavaRow) and pass the result to BASE64Encoder.
Something like that:
byte[] b = out.Content.getBytes();
String s = new sun.misc.BASE64Encoder().encode(b);
row4.Content = s;
If it doesn't solve your problem, let us know.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think you need to convert String to bytes array before to encode.
Here is a example from StackExchange for the conversion:
String example = "Convert Java String"; byte[] bytes = example.getBytes();
You need to put this in the tJava (or tJavaRow) and pass the result to BASE64Encoder.
Something like that:
byte[] b = out.Content.getBytes();
String s = new sun.misc.BASE64Encoder().encode(b);
row4.Content = s;
If it doesn't solve your problem, let us know.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tried this today, but it doesn't seem to work. The source are files in sql strored as binary, and after migrating to SF the files are corrupt and cannot be open. In the SQL metadata, I have setup the column where the data is as a string.
Subjob:
Here is my tJavarow Basic:
output_row.Owner_Id = input_row.Owner_Id;
output_row.Client_Id = input_row.Client_Id;
output_row.Contact_Number = input_row.Contact_Number;
output_row.Record_Id = input_row.Record_Id;
output_row.Description = input_row.Description;
output_row.Ole_Doc_Type = input_row.Ole_Doc_Type;
byte[] b = row3.TextCol.getBytes();
String s = new sun.misc.BASE64Encoder().encode(b);
row4.TextCol = s;
tJavaRow Advance:
import org.apache.commons.codec.binary.Base64;
tmap:
Help would be appreciated, thank you.
