0

onclick = ui.openRecord

Not sure if this is the right place to ask this but I have the following question.
Can the onclick event "ui.openrecord" in a button also be executed in a function in javascript? For example:
<button onclick = ui.openrecord('{id}')>Button</<button>;
I want to execute a function in JavaScript for this to alow other additional script in the function, for example:
<button onclick = "buttonclick()">button</button>
<script>
function buttonclick() {
?????? (what goes here?)
};
</script>

  

6 replies

null
    • Sean
    • 3 mths ago
    • Reported - view

    Yes, it can. This is a simple example.

    let list := (select Table1).Text;
    html("
    <button onclick=""customOpenRecord()"">Open Record</button>
    
    <script>
        function customOpenRecord() {
            ui.openRecord('" + raw(first((select Table1)[Text = item(list, 1)])) + "');
        }
    </script>
    ")

    It opens the record that matches Text in Table1. You can also add more code inside the function.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 3 mths ago
      • Reported - view

      Hi Sean, don´t work something I do wrong you have sample example.

      Appreciate 

      • Sean
      • 3 mths ago
      • Reported - view

       Here is an example database.

      • Ninox partner
      • RoSoft_Steven.1
      • 3 mths ago
      • Reported - view

      Thanks, it works. I must have put too many quotes somewhere....🙄

      • Sean
      • 3 mths ago
      • Reported - view

       Or maybe I created a problem when I made it a one-liner. Glad it’s working for you.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 3 mths ago
      • Reported - view

       

Content aside

  • 3 mths agoLast active
  • 6Replies
  • 125Views
  • 3 Following