Delete data for a selected field IDs

postsauravpostsaurav Posts: 510Member
Hi all,

Good morning.

Please don't ask why i require it but its urgent.

I want to delete all data in all tables for Fields between 50000..99999, i.e i want to delete data from all customize fields in all tables.

How it can be achieved.
Thanks & Regards,
Saurav Dhyani

http://saurav-nav.blogspot.in

Answers

  • ufukufuk Posts: 505Member
    I've cut this from one of my project so there may be some missing parts. Please check it (pk, validation etc.) before using. Hope this helps.
    OBJECT Codeunit 82000 ModifyFieldValuesInRange
    {
      OBJECT-PROPERTIES
      {
        Date=10.08.12;
        Time=10:14:59;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        OnRun=BEGIN
                DeleteValuesInRange(50000,99999,2,100,FALSE);
              END;
    
      }
      CODE
      {
    
        PROCEDURE DeleteValuesInRange@1103301000(TableStartNumber@1103301003 : Integer;TableEndNumber@1103301004 : Integer;FieldStartNumber@1103301006 : Integer;FieldEndNumber@1103301005 : Integer;UseValidation@1103301007 : Boolean);
        VAR
          Field@1103301000 : Record 2000000041;
          FldRef@1103301001 : FieldRef;
          RecRef@1103301002 : RecordRef;
          MigrationMgt@1103301009 : Codeunit 8611;
        BEGIN
          Field.SETRANGE(TableNo,TableStartNumber,TableEndNumber);
          Field.SETRANGE("No.",FieldStartNumber,FieldEndNumber);
          IF Field.FINDSET THEN BEGIN
            REPEAT
              RecRef.OPEN(Field.TableNo);
              IF RecRef.FINDSET(TRUE,FALSE) THEN
                REPEAT
                  FldRef := RecRef.FIELD(Field."No.");
                  MigrationMgt.EvaluateValue(FldRef,'');
                  RecRef.MODIFY;
                UNTIL RecRef.NEXT = 0;
              RecRef.CLOSE;
            UNTIL Field.NEXT = 0;
    
          END;
        END;
    
        BEGIN
        END.
      }
    }
    
    
    Ufuk Asci
    Pargesoft
Sign In or Register to comment.