0

How to implement a button function in Ninox: Create a new record and pop it up?

Hello everyone, can the button function in the HOME table be modified to: create a new record and pop it up?

For someone like me who is just getting familiar with Ninox functions, HTML seems to be another profound subject. Thank you for your help!

Ninox :

let aa := this;
let newJl := (create 'ADD');
popupRecord(newJl)

19 replies

null
    • Fred
    • 13 days ago
    • Reported - view

    Does your code not work?

      • gold_cat
      • 13 days ago
      • Reported - view

       

      The code is working, but I want to change its functionality: to pop up the latest record.

      I came up with a clumsy solution…

      • gold_cat
      • 13 days ago
      • Reported - view

       But there’s a problem. I actually want to add buttons into lists and display them within a formula. Using this method, clicking anywhere within the range creates a record…

      • Fred
      • 13 days ago
      • Reported - view

      Wow, this is a completely different direction.

      What do you mean by "latest record"?

      • gold_cat
      • 13 days ago
      • Reported - view

       

      Just like this piece of code, create a new record and open it afterward, but this button is implemented using HTML.
       

      I want to merge the button with another formula element later...

       said:
      let aa := this;
      let newJl := (create 'ADD');
      popupRecord(newJl)
    • Nick
    • 13 days ago
    • Reported - view

    Try this code in a button:

    popupRecord(create ADD)
      • gold_cat
      • 13 days ago
      • Reported - view

       Thank you for the reply. I want to achieve this within a formula button. How can I do that?

    • Ninox partner
    • RoSoft_Steven.1
    • 13 days ago
    • Reported - view

    There is a trick to do this by using a hidden field where the code is in the trigger after update to create a new record and open it. I have updated your database with an example of this:

    Notes:
    1) make sure the name of the hidden field does not contain spaces or special signs in order to let the function fieldId() to work correctly.

    2) change the binding of the hidden field to "Per record in memory (browser)" to let this work.

      • gold_cat
      • 13 days ago
      • Reported - view

       Thanks Steven for sharing this clever solution!

      • gold_cat
      • 13 days ago
      • Reported - view

       Hi,  Steven on the Mac client, the record pops up and then automatically closes. How can this be resolved?

      • Ninox partner
      • RoSoft_Steven.1
      • 12 days ago
      • Reported - view

       I tried different approaches, even in a button. It's probably a bug in the app version.

      Maybe someone smarter can sort it out?

    • szormpas
    • 12 days ago
    • Reported - view

    Hi, I've tried another approach by combining 'database.create' and 'ui.popupRecord':

    let x := tableId("ADD");
    let y := x + (number(last(select ADD)) + 1);
    html("
    <head>
    <style>
       .szButton {
            border: 1px solid #566eb1;
            color: #566eb1;
            background-color: transparent;
            padding: 2px 20px;
            font-size: 14px;
            border-radius: 4px;
            cursor: pointer;
            text-align: center;
       }
    </style>
    </head>
    <body>
       <button class='szButton' onclick='createAndPopup()'>Create & Open</button>
       <script>
              function createAndPopup() {
                database.create('" +
    x +
    "');
                ui.popupRecord('" +
    y +
    "');
            };
        </script>
    </body>")
    
      • gold_cat
      • 12 days ago
      • Reported - view

       This is a brilliant solution!

      • gold_cat
      • 12 days ago
      • Reported - view

      Hi friend, how can I implement a function to open a table, for example, clicking to open the ADD table?

       

      • Ninox partner
      • RoSoft_Steven.1
      • 12 days ago
      • Reported - view

       

      Yes, by using ui.openTable:

      let x := tableId("ADD");
      html("
      <head>
      <style>
         .szButton {
              border: 1px solid #566eb1;
              color: #566eb1;
              background-color: transparent;
              padding: 2px 20px;
              font-size: 14px;
              border-radius: 4px;
              cursor: pointer;
              text-align: center;
         }
      </style>
      </head>
      <body>
         <button class='szButton' onclick='createAndPopup()'>Opentable</button>
         <script>
                function createAndPopup() {
                  ui.openTable('" +
      x +
      "');
             };
          </script>
      </body>")
      

      these command are valid in Ninox JS:

      • ui.openHome
      • ui.openSearch
      • ui.openCalendar
      • ui.openTable
      • ui.closeAllRecords
      • ui.closeRecord
      • ui.closeFullscreen
      • ui.openFullscreen
      • ui.popupRecord
      • ui.openRecord
      • database.duplicate
      • database.remove
      • database.update
      • database.create
      • Fred
      • 12 days ago
      • Reported - view

      I thought that Ninox is saying that ui.XXX should not be used as support for it will go away in the future.

      • gold_cat
      • 12 days ago
      • Reported - view

       

      Thank you, Steven, for your reply. It has been very helpful to me.

      Unfortunately, this feature will be removed. I have always wanted to integrate the button with a specific chart style, and it was through everyone’s sharing that I learned about this feature…

       

      While using it, I also found some bugs. For example, the newly created record (popupRecord) does not display directly, and the values set by the table function (Trigger on new record) for the new record are not applied. I’m not sure where the error is… for example, as shown in the image.

      • Ninox partner
      • RoSoft_Steven.1
      • 11 days ago
      • Reported - view

       

      I guess that's the reason why the big "Ninox CRM" (due to modularity, only available on private cloud) is using the "second way" version, so Table triggers would still work ...

      This is also why I have the feeling that these ui.xxx will not disappear soon. Maybe a few of them, who knows....

      • Rafael Sanchis
      • Rafael_Sanchis
      • 11 days ago
      • Reported - view

       

      In my case it doesn't work the ui.xxx