0

Multiple records print with button

Hi,

Is there a way to print multiple pages (records) in a button ?

For one page, it already works with this :

let myPdf := printRecord(this, "name");

Actually, I can already do it with the print button in ninox and then select the "all" function but I would like to do it in a button.

Thanks a lot.

Lorenz

Screen Shot 2018-11-06 at 00.36.53

32 replies

null
    • Ninox developper
    • Jacques_TUR
    • 1 yr ago
    • Reported - view

    Please find an example of printing in the attached database. See the ViewEvent table.
    Lots of news on this page:
    - The customer list is retrieved from the 'Customer list' field. This means that the print button takes into account the filter and the order of the list. 
    - The download button asks for the name of the file before downloading it.
    - and, of course, the print button allows you to print multiple records on the same report.
     

      • Sviluppatore Ninox
      • Fabio
      • 1 yr ago
      • Reported - view

      Many thanks  

      • Eichelfr
      • 3 mths ago
      • Reported - view

       Hi Jacques, any news on the printing multiple records at the same time? I´m looking for a solution to this topic with the ninox native print engine? Frank

    • Ninox developper
    • Jacques_TUR
    • 2 days ago
    • Reported - view


    I've found a solution to make the printAndSaveMutiRecord function work again:

    "----------------------------
    printAndSaveMutiRecord
    -----------------------------";
    function printAndSaveMutiRecord(strNids : text,reportName : text) do
        var n := split(replace(strNids, " ", ""), ",");
        #{:text:callback
        var config = {
            nid: n[0],
            nids: n,
            reportName: reportName,
            printAllAndClose: !0
        };
        var old = database.printRich;
        database.printRich = (e, t) => {
            old.call(database, e, (err, result) => {
                callback(database.loadFileURL(result.id, e.name, "application/pdf", !0));
            })
            database.printRich = old
        }
        schemas.schemas.envConfig.openDesigner(database, config);
       }#;
    end;
      • Créateur de bien-être
      • Sebastien_Guillet
      • yesterday
      • Reported - view

       

      Hello,

      Thank you for being able to offer us a solution. I entered the code below in a button but it does not work. The loading remains in a loop and does not stop. I do not get the desired pdf file. Is this a bug in the code or an error on my part?

      function downloadURL(urlFile : text,destFileName : text) do
          #{:text:callback
              fetch(urlFile)
                  .then(resp => resp.blob())
                  .then(blob => {
                      const url = window.URL.createObjectURL(blob);
                      const a = document.createElement('a');
                      a.style.display = 'none';
                      a.href = url;
                      a.download = destFileName;
                      document.body.appendChild(a);
                      a.click();
                      window.URL.revokeObjectURL(url);
                      callback(url.url);
                  })
      }#
      end;
      function printAndSaveMutiRecord(strNids : text,reportName : text) do
          var n := split(replace(strNids, " ", ""), ",");
          #{:text:callback
          var config = {
              nid: n[0],
              nids: n,
              reportName: reportName,
              printAllAndClose: !0
          };
          var old = database.printRich;
          database.printRich = (e, t) => {
              old.call(database, e, (err, result) => {
                  callback(database.loadFileURL(result.id, e.name, "application/pdf", !0));
              })
              database.printRich = old
          }
          schemas.schemas.envConfig.openDesigner(database, config);
         }#
      end;
      let filterStart := 'Début du filtre';
      let filterEnd := 'Fin du filtre';
      let filter := (select Transactions
              where date('Date de facturation') >= filterStart and
              date('Date de facturation') <= filterEnd);
      var urlFile := printAndSaveMutiRecord(concat(filter.string(ID)), "Facture_template_dynamique");
      downloadURL(urlFile, "myFileName.pdf");
      importFile(this, urlFile, "myOtherFileName.pdf")
      
      • Sviluppatore Ninox
      • Fabio
      • yesterday
      • Reported - view

      Hi . Valuable work as always.
      Thank you very much!

      • Ninox developper
      • Jacques_TUR
      • yesterday
      • Reported - view

       I just ran the test again using your code, and it works fine on my end. Which version of Ninox are you using, and on which platform?

      • Créateur de bien-être
      • Sebastien_Guillet
      • yesterday
      • Reported - view

      I'm using the app on Mac version 3.13.16. I just tried on app.ninox.com and it works fine. Thank you very much!

Content aside

  • yesterdayLast active
  • 32Replies
  • 3150Views
  • 5 Following