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.)

16replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • 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

    Like
    • RoSoft_Steven 

      I will try this!

      Like
    • RoSoft_Steven Whoo hoo! Works great.

      Like 1
    • 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

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

      Like
    • 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

       

      Like
    • 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

      Like
    • RoSoft_Steven Beauty!

      Like 1
    • 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.

      Like
    • Kent Signorini Thanks for the perfected addition 👌

      Like
  • 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 

    Like
    • Mel Charles Bizarre.

      Like
      • Fred
      • Fred
      • 2 mths 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.

      Like 1
    • Fred
    • Fred
    • 2 mths 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.

    Like
    • Fred
    • Fred
    • 2 mths 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.

    Like
    • Fred Cool. Thanks.

      Like
Like Follow
  • Status Answered
  • 1 mth agoLast active
  • 16Replies
  • 105Views
  • 4 Following