Tuesday, November 3, 2015

AX 2012: accessing previous value of a field

   Accessing previous value of a field


  *You can try this logic in validate or modified field methods*
            
   DictTable dictTable;
DictField dictField;
tableId tableId;
fieldId fieldId;
#DictField
PurchParmLine purchParmLine;

            if(any2real(this.(_fieldId)) < any2real(this.orig().(_fieldId)))
            {
                
               dicttable = new DictTable(tablenum(PurchParmLine));             
               fieldId   = dictTable.fieldName2Id("ReasonTableRef");
               dictField = dictTable.fieldObject(fieldId);
              // dictField =new DictField(tablenum(PurchParmLine), fieldnum(PurchParmLine,                                  ReasonTableRef));
                if (!dictField.isSystem() && bitTest(dictField.flags(), #dbf_visible)
                && bitTest(dictField.flags(), #dbf_mandatory))
                {
                     info(strfmt("Field number %1 changed from %2 to %3",_fieldId,this.orig().                                          (_fieldId),this.(_fieldId)));
                }
            }

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8