Friday, February 17, 2023

Compare buffer value (source and orig) in D365FO X++

 static server boolean CompareBuffers(Common Buffer1,Common Buffer2,boolean IncludeSystemFields = true)

    {

        Boolean retBool = false;

        DictTable tbl;

        DictField fld;

        int fldCnt;

        int fldIdx;

        int TblId;

        int fldId;


        /*

        if(!Buffer1 || ! Buffer2)

        {

            info("Atleast 1 buffer is null");

            return retBool;

        }

        */

        if(!(Buffer1.TableId > 0) || (Buffer1.TableId != Buffer2.TableId))

        {

            info("The Tale buffers are not Valid");

        }


       tblId = buffer1.TableId;

       tbl = new DictTable(tblId);


       fldCnt = tbl.fieldCnt();

        for(fldIdx = 1; fldIdx <= fldCnt; fldIdx++)

        {

            fldId = tbl.fieldCnt2Id(fldIdx);

           fld = new DictField(TblId,fldId);

           if(!fld.isSystem() || InCludeSystemFields)

           {

                if(buffer1.(fldId) != buffer2.(fldId))

                {

                    info(strfmt("The Field %1 is different. buffer1.%1 = %2 , Buffer2.%1 = %3",FieldId2Name(tbl.id(),fldId),buffer1.(fldId),buffer2.(fldId)));

                    return retBool;

                }

           }

        }


        retbool = true;

        return retbool;

    }

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...