how can i find blank field in table

vijay_gvijay_g Member Posts: 884
hi,
can anybody tell me that how can i find any table fields that not have value means that is blank with all records.

Comments

  • DaveTDaveT Member Posts: 1,039
    Hi,

    Not sure what you want to do :?
    do you want to do this through code or manually?
    Manually: filter the field for <>''
    Code: You can filter on the field <>'' and check the COUNT
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • vijay_gvijay_g Member Posts: 884
    hi Mr. DaveT,
    actually my requirement is that i want a list of all field in tables that is blank(also that have default value for all data type) in a form of report or form by coding. so that i could find these are fields in those tables are blank.
    eg..
    table no. field no. field name
    18 13707 T.I.N no
  • DenSterDenSter Member Posts: 8,304
    Is that so you can disable those fields and add more yourself? If so, be aware that when you disable fields, you essentially restrict your customer from ever using the functionality that is served by that field.
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    DaveT wrote:
    Code: You can filter on the field <>'' and check the COUNT
    I would rather set filter using SETFILTER(Field,'<>%1', '') and then used ISEMPTY.

    The code could look as below:
    RecRef - variable of RecordRef type
    fref - variable of FieldRef type
    skipcheck - Boolean
    RecRef.OPEN(18);
    FOR i:= 1 TO RecRef.FIELDCOUNT DO BEGIN
      Fref := RecRef.FIELDINDEX(i);
      skipcheck := FALSE;
      CASE FORMAT(Fref.TYPE) OF
        'Code','Text'                             : Fref.SETFILTER('<>%1', '');
        'Integer','BigInteger','Decimal', 'Option': Fref.SETFILTER('<>%1', 0);
        'Date'                                    : Fref.SETFILTER('<>%1', 0D);
        'Time'                                    : Fref.SETFILTER('<>%1', 0T);
        'DateTime'                                : Fref.SETFILTER('<>%1', 0DT);
        ELSE
          skipcheck := TRUE;
      END;
      IF FORMAT(Fref.CLASS) <> 'Normal' THEN  // skip Flowfields and Flowfilters
        skipcheck := TRUE;
      IF NOT skipcheck AND RecRef.ISEMPTY THEN BEGIN
        // here you know that field referenced by Fref variable is empty 
        // in all records in ther table referenced by RecRef
        MESSAGE('Empty %1 in table %2', Fref.CAPTION, RecRef.CAPTION);
      END;
      Fref.SETRANGE();
    END;
    recref.CLOSE();
    
    The above allows you to find all empty fields in any table (in the example above table 18 Customer is checked).
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • vijay_gvijay_g Member Posts: 884
    hi Slawek Guzek,
    thank you very much, but this code is not cover dateformula datatype that is generally used so if i want to do 4 it or what would be write instead of this like " Fref.SETFILTER('<>%1', 0DT);"

    thanx in advance
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    vijay_g wrote:
    what would be write instead of this like " Fref.SETFILTER('<>%1', 0DT);"
    Sorry. That is puzzle to solve by you. Learn, don't copy only.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • vijay_gvijay_g Member Posts: 884
    i have already maked it but the problem is only for datefurmula data type becoz there is no any fix value for this data type like 1m,15d,1w...etc...so i could be write any condition for it.
  • garakgarak Member Posts: 3,263
    Try to use the search the forum function first ;-)

    viewtopic.php?f=23&t=36547
    Do you make it right, it works too!
Sign In or Register to comment.