Skip to main content
Nintex Community Menu Bar

I’m trying to find some examples of functions that can be run with JS-Insert. Specifically, I’m trying to base64 decode a string. I’m hoping I can run the atob() function against a field that contains the encoded string. Currently, the control just shows me whatever I type into the ‘JS to Execute’ field. Does anyone have any insight into how to accomplish this?

Hi ​@LukeR,

Here is an example of how to achieve your solution using the JS-Insert plugin from the gallery.

I will start by adding a Text-Short control to my form.
I have given it a default value (optional).
Add a CSS class of base64Input.  This is a must so that jQuery can reference the control.
 


Next, I have added a label control and given it a CSS class of decodedOutput.
 

Add the JS-Insert control.
Configure it to be visible No.
JS to execute is:

  $('.base64Input input').on('blur', function() {
var base64String = $(this).val().trim();
try {
var decodedString = atob(base64String);
$('.decodedOutput').text(decodedString);
} catch (e) {
$('.decodedOutput').text('Invalid Base64 string.');
}
});

Test:
On blur, the form will look like this:
 


This is what the form looks like in the designer.
 

 


Thanks, Simon! That’s exactly what I was needing!


Reply