Discussions

 View Only
  • 1.  Checking for Duplicates in a Field in Other Records

    Posted 06-01-2022 14:15
    How would I check to see if a field has the same value in the same field in other records after clicking Save and Close?  Can a pop up show saying the field on this record is a duplicate to the field on a different record?  Also, check only if a checkbox is not checked?  If the checkbox is checked don't check at all.

    Thanks
    Brian

    ------------------------------
    Brian Dunk
    ------------------------------


  • 2.  RE: Checking for Duplicates in a Field in Other Records

    Posted 06-01-2022 19:51
    try this as a formula Checkbox field type. Replace the 232 with the field which is the potential duplicate and of course use your own fields in the square brackets.

    var text QUERY =
    "{232.EX." & [Possible duplicate field] & "}"

    var bool LookForDuplicates =
    Size(
    GetRecords($QUERY)) >1;

    IF([my checkbox field]=false, $LookForDuplicates)

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 3.  RE: Checking for Duplicates in a Field in Other Records

    Posted 08-03-2022 11:02
    Hey Mark quick question on this.  If I wanted to add another checkbox to my form to control whether to check for duplicates or not could I add the following code to my "Dupicate" formula field?  
    The code currently is the following:
    var text QUERY = "{6.EX." & [Container Number] & "}";
    var bool LookForDuplicates = Size(GetRecords($QUERY))>1;
    If([Domestic]=false, $LookForDuplicates)

    Could I add the following to add another checkbox called "Consolidated Shipment" to control whether to look for duplicates?
    If([Consolidated Shipment]=false, $LookForDuplicates)

    Thanks 
    Brian

    ------------------------------
    Brian Dunk
    ------------------------------



  • 4.  RE: Checking for Duplicates in a Field in Other Records

    Posted 08-03-2022 11:06
    looks right to me, give it a try.

    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------



  • 5.  RE: Checking for Duplicates in a Field in Other Records

    Posted 08-08-2022 10:30
    Hi Mark, so I tried adding that IF statement and it gave me an error so I went with the following but I am not so sure it is working as I hoped.  Can you tell me if this would be correct?

    var text QUERY = "{6.EX." & [Container Number] & "}";
    var bool LookForDuplicates = Size(GetRecords($QUERY))>1;
    If([Domestic]or[Consolidated Shipment]=false, $LookForDuplicates)

    ------------------------------
    Brian Dunk
    ------------------------------



  • 6.  RE: Checking for Duplicates in a Field in Other Records

    Posted 08-08-2022 22:36
    If there is an error you need to copy and paste the error.

    As for the logic, can you say in words when you want to check for duplicates?  Under what conditions?


    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------



  • 7.  RE: Checking for Duplicates in a Field in Other Records

    Posted 08-12-2022 08:49
    Edited by Brian Dunk 08-12-2022 08:50
    Ok...when I have the code as the following I get this error:
    var text QUERY = "{6.EX." & [Container Number] & "}";
    var bool LookForDuplicates = Size(GetRecords($QUERY))>1;
    If([Domestic]=false, $LookForDuplicates)
    If([Consolidated Shipment]=false, $LookForDuplicates)

    So then when I change to this:
    var text QUERY = "{6.EX." & [Container Number] & "}";
    var bool LookForDuplicates = Size(GetRecords($QUERY))>1;
    If([Domestic]or[Consolidated Shipment]=false, $LookForDuplicates)

    Now when I select the "Domestic" checkbox it will not allow me to save.  I thought, with the code above, if I checked the either checkbox it would turn off the duplicate checking.

    I only want to check for duplicates when both the "Domestic" or "Conslolidated Shipment" checkboxes are NOT checked.  If either one is checked,  do not check for duplicates.

    ------------------------------
    Brian Dunk
    ------------------------------



  • 8.  RE: Checking for Duplicates in a Field in Other Records

    Posted 08-12-2022 20:18
    Try this

    var text QUERY = "{6.EX." & [Container Number] & "}";

    var bool LookForDuplicates = Size(GetRecords($QUERY))>1;

    If(not [Domestic] and not [Consolidated Shipment], $LookForDuplicates)

    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------