Skip to main content
Nintex Community Menu Bar
Question

How do you decode a base64 field?

  • Jul 10, 2024 12:04 PM UTC
  • 9 replies
  • 174 views
  • Translate All

Forum|alt.badge.img+7

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

thanks

9 replies

Forum|alt.badge.img+8

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

Translate

Forum|alt.badge.img+8
  • Jul 10, 2024 1:13 PM UTC

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

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

The value displays as
W29iamVjdCBPYmplY3Rd

Do you have an example for custom rendering base64 field?

Thanks.

Translate

Forum|alt.badge.img+1
  • Jul 10, 2024 1:13 PM UTC

@Jaime were you able to decode base64 field?

Translate

Forum|alt.badge.img+11
  • Jul 10, 2024 1:13 PM UTC

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

Translate

Forum|alt.badge.img+1
  • Jul 10, 2024 1:13 PM UTC

@Germany Content field on Content Note object.

Translate

Forum|alt.badge.img+17
  • Nintex Employee
  • Jul 10, 2024 1:13 PM UTC

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.

Translate

Forum|alt.badge.img+1
  • Jul 10, 2024 1:13 PM UTC

Thanks @Rob_Hatch I will try it out.

Translate

Forum|alt.badge.img+11
  • Jul 10, 2024 1:13 PM UTC

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

Thanks,

Translate

Forum|alt.badge.img+1
  • Jul 10, 2024 1:13 PM UTC

Thanks @Rob_Hatch. Worked perfectly.

@Germany was able to get it working.

Translate