0

How to enforce unique values in text field?

Is it possible to define a text field to contain unique values only (no duplicates)?

10 replies

null
    • Support
    • 5 yrs ago
    • Reported - view

    Hi,

    If I understand you right you want to ensure that you are not inserting duplicates during the input. 

    That can be done with a formula on the "Trigger on Update" in the options of the datafield:

     

    let myInput := Table1.'Text_field';
    if cnt((select Table1)['Text_field' = myInput]) > 1 then
    alert("Duplicate, choose another value.");
    'Text_field' := null
    end

     

    Best regards, J枚rg

    • Laurent
    • 5 yrs ago
    • Reported - view

    +1

    • michaelbroesdorf
    • 5 yrs ago
    • Reported - view

    yes, that is exactly what I was looking for - thanks a lot!

    • Personal
    • Art
    • 4 yrs ago
    • Reported - view

    Thank you, this was helpful.

    • Rusty
    • 3 yrs ago
    • Reported - view

    uhm.... Table1.'Text_field' not work for me. I can't select the table in formula.... 

    • individual
    • ekaterina
    • 2 yrs ago
    • Reported - view

    GooD!

    • BAJABI SL
    • jjrecort
    • 1 yr ago
    • Reported - view

    Thanks a lot, Jorg, It Seems to be working for me, but it just erases the duplicated serial, and no alert appears. I'm my case, I need unique serial numbers

     

    this is my code

    let myInput := Serial;
    if cnt((select Stock)[Serial = myInput]) > 1 then
        alert("Already in Stock!");
        Serial := null
    end

     

    I'm new at NINOX, coming from Filemaker, which is just a checkbox on the field options menu.

    Thanks a lot.

      • Alan_Cooke
      • 1 yr ago
      • Reported - view

      jjrecort If you are using the Cloud version alerts do not work on Trigger after update.  I had exacty the same issue (serial numbers and have resolved it this way.
      I have a field "SERIAL NUMBER" and a Text field named:  "DUPLICATE FLAG" (Display if: set to null as default.  I have a Formula field named "Duplicate Flag Display" who's formula is 'DUPLICATE FLAG' - style set to red.

      Code:

      let xCurrRec := number(Id);
      'SERIAL NUMBER' := upper('SERIAL NUMBER');
      let xSN := 'SERIAL NUMBER';
      "Scans table for duplicate serial numbers";
      if 'SERIAL NUMBER' != null then
          let x := cnt((select 'Project Equipment')['SERIAL NUMBER' = xSN]);
          if x > 1 then
              'DUPLICATE FLAG' := "!! DUPLICATE SERIAL NUMBER !!"
          else
              'DUPLICATE FLAG' := null
          end
      end;
      dupe01(xSN, xCurrRec, 'DUPLICATE FLAG')

      Let me know if this works for you.  If not I can help.

    • BAJABI SL
    • jjrecort
    • 1 yr ago
    • Reported - view

    Thanks a lot, Alan!

    I'm very new to NINOX, and I just discovered yesterday there are two versions of NINOX: Desktop app and web-based, which I guess is the NINOX Cloud.

    I solved it with the following lines.

     

    let myInput := Serial;
    if cnt((select Stock)[Serial = myInput]) > 1 then
        alert("Already in Stock!");
        Serial := "Duplicat"
    end

     

    I'm keeping the original alert, just in case I move to the desktop app.

    If my input is a duplicated serial number, then I get the "Duplicated Serial" directly on the field

    This way is very clean and visual for the user.

     

    Now to fight on how to lookup data from other tables without manual input! :)))

     

    Thanks a lot!

      • BAJABI SL
      • jjrecort
      • 1 yr ago
      • Reported - view

      Alan Cooke

Content aside

  • 1 yr agoLast active
  • 10Replies
  • 2843Views
  • 2 Following