How do you decode a base64 field?

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.

ExpandedNotes.txt

Hopefully this works for you.