adsenseheader

Tuesday, January 18, 2022

Copy Data From One Table To Another Table By Using buf2buf- D365FO

Hello Guys...! Some times we get requirement like , we have to copy data from one table to other table . For that we created a new static method. This method we can use if our second table fields Id's are same as First table field Id's. Here in the example we are copying data from Staging table to Target table.
static void buf2Buf(Common  _from,
                                Common  _to,
                                TableScope _scope = TableScope::CurrentTableOnly)
    {
        var         dictTable = new DictTable(_to.TableId);
        int64       tableId;
        FieldId     fieldId = dictTable.fieldNext(0, _scope);

        while (fieldId && ! isSysId(fieldId))
        {
            _to.(fieldId)   = _from.(fieldName2Id(_from.tableId,fieldId2Name(_to.tableId,fieldId)));
            fieldId         = dictTable.fieldNext(fieldId, _scope);
        }
    } 

No comments:

Post a Comment