Skip to main content

I have a salesforce field of base64 type that I need to decode?  How would I do that in a custom renderer?

thanks

I think bota and atob would be the functions you would want to decode and encode base 64 strings in javascript. https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding


Hi I’m trying to use the new contentnote object. In the custom render for the content field in a list view:
value1 = argumentst1];
text = window.atob(value1);
skuid.ui.fieldRenderersr‘TEXTAREA’]field.mode;

In the custom render for the content field in a field editor:
value1 = argumentsu1];
text = window.btoa(value1);
skuid.ui.fieldRenderersd‘TEXTAREA’]field.mode;

The value displays as
W29iamVjdCBPYmplY3Rd

Do you have an example for custom rendering base64 field?

Thanks.


@Jaime were you able to decode base64 field?


@Mohnish can you share an example of the base64 field you are trying to decode?


@Germany Content field on Content Note object.


I was looking back at some old notes from our Documentation team, and Cody has created a solution for this. He built a custom formula function that encodes and decodes Base64 fields. You can add this custom function to your page as an “Inline” javascript resource and then create a UI Only Formual field that decodes the Content note of the ContentNote record.

Here is the custom formula function:

skuid.formula.Formula (
'base64encode',
function (fieldName) {
var encodedData = window.btoa(fieldName);
return encodedData;
},{
numArgs : 1,
returnType : 'string'
}
);
skuid.formula.Formula (
'base64decode',
function (fieldName) {
var decodedData = window.atob(fieldName);
return decodedData;
},{
numArgs : 1,
returnType : 'string'
}
);

Here is the documentation for custom formula functions.
https://docs.skuid.com/latest/v2/en/skuid/api/skuid_formula.html#skuid-formula

  • A few notes. Because of the way the content note record is stored as a nested array - the ui only formula field will look like this:
c__base64decode({{{Content.asByteArray}}})
  • You will have to do some XML conversion of the UI only Formula field so that the output type is of type "TextArea" and the "RichTexts" property is true. Then the HTML will be interpreted at run time - and not just escaped.
  • Any styling for the content note will need to come from the parent page. This will probably best be delivered if the page is in a Lightning Component and delivered in a Lightning App Builder page. Otherwize you will need to address a bunch of styling...

Finally - I’ve attached my working page to this ticket. Its not a finished product, but does the base64 decoding. If you download this file and change the extension to .xml - you will be able to easily upload it into a new page.

Hopefully this works for you.


Thanks @Rob_Hatch I will try it out.


Hey, @Mohnish, just wanted to follow up. Any luck?


Thanks,


Thanks @Rob_Hatch. Worked perfectly.


@Germany was able to get it working.


Reply