0

Two Serious Problems... Required Fields & Trigger on new record/update

I just realized there are two serious problems that might be deal-breakers for my business.

1. Required fields don't seem too required. That is to say, I can close a record and it saves (because it enters the database on creation) but it can be closed without Required fields actually being filled out. How is that Required? How does everyone else handle this?

2. I can't seem to get scripts running on a table's Trigger on new record, or Trigger on update. Do these not actually do anything?

(I'm on web.)

18 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 1 yr ago
    • Reported - view

    Kent Signorini

    What works for me is using the trigger after hide of the tabelement. What I do is create a tabelement, drag it to the first place of the fields list. (When you use the "Edit Fields" command)

    Now you can even use a different backgroundcolor for your form and/or change the title.

    Then I select the Tab element and under more options you find the trigger after hide.

    There you can program to check if required fields are filled. e.g.:

    let me := this;
    if not 'Booking#' then
        let responce := dialog("Warning", "Field Booking# is still empty! Delete this record?", ["Yes", "No"]);
        if responce = "Yes" then
            delete me
        else
            if responce = "No" then popupRecord(me) end
        end
    end

    Steven

      • Kent_Signorini
      • 1 yr ago
      • Reported - view

      RoSoft_Steven 

      I will try this!

      • Kent_Signorini
      • 1 yr ago
      • Reported - view

      RoSoft_Steven Whoo hoo! Works great.

      • Mel_Charles
      • 1 yr ago
      • Reported - view

      Kent Signorini Steven has given a great answer to your first question (as usual 😉

      I too and on the web version (multiple users) and have no issues generally with forms scripts running for New or Update records..

      There are a few commands that have issues on the web version at the form level that are useable in the app version, ie like alert! but that apart all is good. See list on following post

      So is there a specific script/task that you are trying to achieve we can help you with?

      Kind regards

      Mel

      • Kent_Signorini
      • 1 yr ago
      • Reported - view

      Mel Charles I think I got it all worked out now. Thanks!

      • Kent_Signorini
      • 1 yr ago
      • Reported - view

      RoSoft_Steven 

      So I'm trying to write some code to do this for multiple fields. It works but looks terrible, since the text--although on a new line as expected--isn't lined up. Any idea why it's not lining up the "Pet Name" text and the "Sex" text?

      let t := this;
      let m := "";
      if not 'Pet Name *' then
          m := m + "Pet Name
          "
      end;
      if not 'Sex *' then
          m := m + "Sex
          "
      end;
      m := "You must provide the following information:
      
      " + m;
      if not 'Pet Name *' or not 'Sex *' then
          let r := dialog("Warning", m, ["Continue Editing", "Delete Record"]);
          if r = "Delete Record" then
              delete t
          else
              if r = "Continue Editing" then
                  popupRecord(t)
              end
          end
      end

       

      • Ninox partner
      • RoSoft_Steven.1
      • 1 yr ago
      • Reported - view

      Kent Signorini 

      If you love styled dialogboxes, you'll love this! Dialog boxes accepts html styling:

      try this:

      let t := this;
      let m := "<ul>";
      if not 'Pet Name *' then
          m := m + "
          <li>Pet Name</li>"
      end;
      if not 'Sex *' then
          m := m + "
          <li>Sex</li>"
      end;
      m := "<p style='background-color:coral;font-size:160%;text-align:center;color:white;'>You must provide the following information:</p>" + m + "</ul>";
      if not 'Pet Name *' or not 'Sex *' then
          let r := dialog("Warning", m, ["Continue Editing", "Delete Record"]);
          if r = "Delete Record" then
              delete t
          else
              if r = "Continue Editing" then
                  popupRecord(t)
              end
          end
      end
      

       

      Steven

      • Kent_Signorini
      • 1 yr ago
      • Reported - view

      RoSoft_Steven Beauty!

      • Kent_Signorini
      • 1 yr ago
      • Reported - view

      RoSoft_Steven 

      One more addition:

      let t := this;
      if t.Id != null then
          let m := "<ul>";
          if not 'Pet Name *' then
              m := m + "
              <li>Pet Name</li>"
          end;
          if not 'Sex *' then
              m := m + "
              <li>Sex</li>"
          end;
          m := "<p style='background-color:coral;font-size:160%;text-align:center;color:white;'>You must provide the following information:</p>" + m + "</ul>";
          if not 'Pet Name *' or not 'Sex *' then
              let r := dialog("Warning", m, ["Continue Editing", "Delete Record"]);
              if r = "Delete Record" then
                  delete t
              else
                  if r = "Continue Editing" then
                      popupRecord(t)
                  end
              end
          end
      end
      

      Adding the check for t.Id != null will avoid popping the dialog box after deleting a record.

      • Ninox partner
      • RoSoft_Steven.1
      • 1 yr ago
      • Reported - view

      Kent Signorini Thanks for the perfected addition 👌

    • Mel_Charles
    • 1 yr ago
    • Reported - view

    here are some functions that are not supported on triggers ("on create" and "after update" in the table) in the web browser version but only in buttons and on the "Trigger after open" in the database options:

    - alert()

    - openTable() 

    - popupRecord()

    - dialog() 

     

    In the Ninox Apps the functions are supported 

      • Kent_Signorini
      • 1 yr ago
      • Reported - view

      Mel Charles Bizarre.

      • Fred
      • 1 yr ago
      • Reported - view

      Kent Signorini It is not actually too "bizarre". On the cloud version, those triggers happen on the server side. Where the server is the "user" doing the action. The items listed are all user related so any alerts and dialogs that show up would show up on server so there is no reason for those actions to happen.

      I didn't know openTable and popupRecords don't work on those triggers for the cloud version.

      On the MacOS app, since the app is the server and user all those functions work.

    • Fred
    • 1 yr ago
    • Reported - view

    Food for thought.

    Another way to do this is to take control using Dashboards. You can create a dashboard that users use to input data then before you create the new record you can check for any required fields.

    Dashboards can also be used for security purposes since users never get access to the raw tables you have added a layer of protection.

    I think it is better in a multi-user environment to NOT let users access the raw data tables directly.

      • John_Wilmans
      • 5 mths ago
      • Reported - view

       Just saw this post and I would love to have more info on this. Do you know of anywhere that I can learn about how to do this better please?

    • Fred
    • 1 yr ago
    • Reported - view
    Kent Signorini said:
    So I'm trying to write some code to do this for multiple fields.

    Take a look at this post and see how you can create it without using a bunch of if statements. Those get crazy if you need to check more than three.

      • Kent_Signorini
      • 1 yr ago
      • Reported - view

      Fred Cool. Thanks.

    • Fred
    • 5 mths ago
    • Reported - view
     said:
    Do you know of anywhere that I can learn about how to do this better please?

     Do a search for Ninox Dashboards on the web and there are video links from Ninox and Nioxius. Though, now if you are on public/private cloud you would use pages instead of creating a table, add a record, then a new form view, etc.

Content aside

  • Status Answered
  • 5 mths agoLast active
  • 18Replies
  • 212Views
  • 5 Following