Identify which field has been modify in table

vijay_gvijay_g Member Posts: 884
Hi
can any body help me out in finding the paticular modified field in table.(i.e if i modify UOM then changed field (i.e unit of measure )is reflect on modify trigger.)

Answers

  • MBergerMBerger Member Posts: 413
    there are 2 ways : you can check Currfieldno, this has the number of the field the USER changed. it is NOT filled when changing something via code. teh other way is comparing every field in Rec with the same in xRec in the OnModify trigger
  • vijay_gvijay_g Member Posts: 884
    How it will work..?
    i have just put message('%1',CurrFieldNo) on modify trigger of item table and at run time i am modifying to description then system returns 0 why? ](*,)
  • MBergerMBerger Member Posts: 413
    vijay_g wrote:
    How it will work..?
    i have just put message('%1',CurrFieldNo) on modify trigger of item table and at run time i am modifying to description then system returns 0 why? ](*,)
    Like i stated, CurrfieldNo only has the value of the (originally) changed field when it is done by a user via a form. look it up in the helpfile !
  • vijay_gvijay_g Member Posts: 884
    it has solved thxxxx
  • AsallaiAsallai Member Posts: 142
    edited 2025-02-05
    MBerger wrote: »
    there are 2 ways : you can check Currfieldno, this has the number of the field the USER changed. it is NOT filled when changing something via code. teh other way is comparing every field in Rec with the same in xRec in the OnModify trigger

    I have also this question, but avoid to handle the page itself. There could be several other Page objects to the same Table object, but to handle every page individually is not the way I think.
    To have a general solution, which field was changed, check COD423 "Change Log Management"

    It's seems doing a simple iteration to check which field's value is changed (Rec vs xRec):
    [External] LogModification(VAR RecRef : RecordRef)
    IF RecRef.ISTEMPORARY THEN
      EXIT;
    
    IF NOT IsLogActive(RecRef.NUMBER,0,1) THEN
      EXIT;
    
    xRecRef.OPEN(RecRef.NUMBER);
    xRecRef."SECURITYFILTERING" := SECURITYFILTER::Filtered;
    IF xRecRef.READPERMISSION THEN BEGIN
      IsReadable := TRUE;
      IF NOT xRecRef.GET(RecRef.RECORDID) THEN
        EXIT;
    END;
    
    FOR i := 1 TO RecRef.FIELDCOUNT DO BEGIN
      FldRef := RecRef.FIELDINDEX(i);
      xFldRef := xRecRef.FIELDINDEX(i);
      IF IsNormalField(FldRef) THEN
        IF FORMAT(FldRef.VALUE) <> FORMAT(xFldRef.VALUE) THEN
          IF IsLogActive(RecRef.NUMBER,FldRef.NUMBER,1) THEN
            InsertLogEntry(FldRef,xFldRef,RecRef,1,IsReadable);
    END;
    
Sign In or Register to comment.