Uploaded image for project: 'Proforma Server & Data Centre'
  1. Proforma Server & Data Centre
  2. FORMDC-75

Click `Response (XLSX)` button in project form list does not start download.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Low Low
    • None
    • None
    • Export and Reporting
    • 2
    • Severity 3 - Minor

      Issue Summary

      This is reproducible on Data Center: (no)

      Steps to Reproduce

      1. Create a template form for a project
      2. Click ... on the right and then click `Response (XLSX)`

      Expected Results

      It should show a flag with progress, and a flag with download link after it's ready.

      Actual Results

      After click the button:

      1. The API calls to prepare file is called
      2. The API calls to check download readiness returns completes
      3. There is neither progress flag nor download flag for user to download the file.

      Workaround

      Use F12 to open devtool and go to console, or use shortcut Ctrl Shift J (on Windows) or Cmd Option J (on Mac) to go to console.

      Find <Project-Key>, <Form-Id> and use then paste and run following code.

      ```
      function downloadFormResponseXLSX(key, id) {
      fetch(`/rest/proforma/api/2/reports/all-form-responses/${key}/${id}`,

      { method: "POST", }

      )
      .then((res) => res.json())
      .then(
      (resJson) => new Promise((resolve) => { const taskId = resJson.id;
      let resolved = false; const resolveOnce = () => { if (!resolved)

      { resolve(taskId); resolved = true; }

      };
      let interval = setInterval(() => {
      fetch(
      `/rest/proforma/api/2/reports/all-form-responses/${key}/${id}/${taskId}`
      )
      .then((res) => res.json())
      .then((resJson) => { if (resJson.status.complete)

      { clearInterval(interval); interval = null; resolveOnce(); }

      });
      }, 300);
      setTimeout(() => { if (interval)

      { console.log("Download timeout for 10 sec."); clearInterval(interval); interval = null; }

      }, 10000);
      })
      )
      .then((taskId) =>
      fetch(
      `/rest/proforma/api/2/reports/all-form-responses/${key}/${id}/${taskId}/ProForma-${key}form${id}.xlsx`
      )
      .then((r) => r.blob())
      .then((xlsxBlob) => { const downloadLink = window.document.createElement("a");
      downloadLink.href = URL.createObjectURL(xlsxBlob);
      downloadLink.setAttribute( "download",
      `ProForma-${key}form${id}.xlsx`
      );
      window.document.body.appendChild(downloadLink);
      downloadLink.click();
      window.document.body.removeChild(downloadLink);
      })
      );
      }

      downloadFormResponseXLSX(<Project-Key>, <Form-Id>);

              Unassigned Unassigned
              77520d6f2646 Lee Wang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: