Forum Discussion

ShaneMiller1's avatar
Qrew Cadet
2 years ago

javascript code page not working

I was following a tutorial to capture a quickbase record as html, then save it as a pdf and place that pdf in an attachment field within the record itself: (

I followed the steps in the link above and all I am getting it to do is open the form as a popup but nothing is saved as a PDF in my attachment field.
I ran the Javascript code through an analyzer (codepen) and found this error (see attached):
'{a}' is only available in ES{b} (use 'esversion: {b}').

Anyone have any ideas on how to resolve this error?
Thank you in advance


9 Replies

  • Can you post the code from the code page?  (redact your private info)

    Jeff Peterson
    • ShaneMiller1's avatar
      Qrew Cadet
      Hey Jeff,
      Thank you for getting back to me. Yes, it's actually the same code that is on the linked discussion. It appears you actually got it all to work as well!
      Here is the Javascript:
      let urlParams = new URLSearchParams(;
      let dbid = urlParams.get("myDbid");
      let recId = urlParams.get('recId');  
      let myForm = urlParams.get('myFormId');
      let usertoken = urlParams.get('usertoken');
      let apptoken = urlParams.get('apptoken');  
      let root = location.protocol + '//' +;
      let myURL = `${root}/db/${dbid}?a=API_GetRecordAsHTML&rid=${recId}&dfid=${myForm}&apptoken=${apptoken}`;
      let myHostName = "";
      const getURL = () => {
          $.post(myURL, {}, function (response) {
      const getDom = () => {
          let myDoc = document.getElementById("dbFormContainer");
          var opt = {
              margin: 1,
              filename: 'myfile.pdf',
              image: { type: 'jpeg', quality: 0.98 },
              html2canvas: { scale: 2 },
              jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }
          html2pdf().from(myDoc).set(opt).outputPdf('dataurlstring').then(async res => {
            var base64result = res.split(',')[1];
            var headers = {
                'QB-Realm-Hostname': myHostName,
                'User-Agent': 'File_Upload',
                'Authorization': `QB-USER-TOKEN ${usertoken}`,
                'Content-Type': 'application/json'
            // 59 is my attachment field. Replace it with yours.
            body = { "to": dbid, "data": [{"3": {"value": recId}, "59": { "value": { "fileName": "FormPDF.pdf", "data": base64result }}  }], "fieldsToReturn": [ 3, 59 ] }
                method: 'POST',
                headers: headers,
                body: JSON.stringify(body)
            .then(async res => {
              if (res.ok) {
                return res.json().then(res => {
              return res.json().then(resBody => Promise.reject({status: res.status, ...resBody}));
          .catch(err => console.log(err))

      The only two things that were changed on this code was my host name for the variable $myHostName and the attachment field ID. Everything else was left the same

      Shane Miller
      • ShaneMiller1's avatar
        Qrew Cadet
        Would you like me to include the HTML code page, as well as the formula text field on the form?

        Shane Miller