JS - Base64

  • 0
  • 1
  • Question
  • Updated 2 months ago
  • In Progress
OK QuickBase Smarty Pants, I need some serious help!  Here is my situation:

I have 3 fields:
1 - [URL] - (URL) Holds the URL for the media file I want to upload later
1 - [Formula] - (Formula text) Formula below to go to the internet & finds the Base64-encoding for the [URL] field and puts the Base64 value in the [Base64] field.
1 - [Base64] - (Text) Holds the Base64 value that will be used in my API to upload the media file into my QuickBase record.

I am using the following formula to take the [URL] field & put the Base64 code into the [Base64] field.  However, I am receiving a syntax error.  I have been looking over it and can not find anything wrong.  Could it be my field type or am I actually missing something in my formula?

var url = "https://raw.github.com/carlo/jquery-base64/master/jquery.base64.min.js";
$.getScript(url,function(){
  $("#_fid_6").on("blur",function(){
    $("#_fid_15").val($.base64.encode($("#_fid_6").val())
  });
});
Photo of Amber Polston

Amber Polston

  • 582 Points 500 badge 2x thumb

Posted 2 months ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
I'm not sure if this is supposed to be whole formula or a part of a larger  formula (as a formula cannot just be the part with the formula variable)  but for the formula variable part you need to begin with

var text url = 


If the entire thing is one long code block - I think you have syntax errors due to " and '

The entire thing has to be wrapped in " " because thats how QB interprets a formula like this. So instead of having "#_fid_6" you need to do '#_fid_6'

More along the lines of 
"var url = 'https://raw.github.com/carlo/jquery-base64/master/jquery.base64.min.js&quot';
$.getScript(url,function(){ 
  $('#_fid_6').on('blur',function(){  
.....

You can't have " in the actual code block - unless you want to put a back slash in front of it like \" to make it interpret it literally

Chayce Duncan | Technical Lead
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base
(Edited)