AX 2012: crossCompany insert_recordset

Although we cannot use crossCompany keyword with insert_recordset command, we can still achieve the same functionality with some performance overhead as follows:

static void JobCCIns(Args _args)
{
    Table21 tab21;
    Table22 tab22;

    ttsBegin;
    while select crossCompany actionDate, name, dataAreaId from tab21
        where tab21.actionDate > str2Date('1998-01-22', 321)
    {
        changeCompany(tab21.dataAreaId)
        {
            tab22 = null;
            tab22.actionDate = tab21.actionDate;
            tab22.name = tab21.name;
            tab22.insert();
        }
    }
    ttsCommit;
}

Leave a comment

Blog at WordPress.com.

Up ↑