RSS

Error Cannot create a record in TmpLedgerJournalPost TmpLedgerJournalPost). Insert operations are not allowed across companies. Please use changecompany keyword to change the current company before inserting the record.

20 Apr

There is a bug with changeCompany keyword which prevents usage of the same initialized table buffer in different companies. For example, in the following code:

LedgerJournalTrans ledgerJournalTrans;

changecompany(company)
{
ttsbegin;

if(this.parmLedgerJournalTable().RecId)
{
tmpLedgerJournalPost.JournalNum = this.parmLedgerJournalTable().JournalNum;
tmpLedgerJournalPost.Branch = ledgerTransactionVoucher.Branch;
tmpLedgerJournalPost.VoucherType= ledgerTransactionVoucher.VoucherType;
tmpLedgerJournalPost.TransDate = ledgerTransactionVoucher.TransDate;
tmpLedgerJournalPost.Company = ledgerTransactionVoucher.Company;
tmpLedgerJournalPost.insert();
}
//further operations
}

crosscompany error

Issue
On usage of change company keyword also the table buffers will hold the old values, so its necessary to explicitly clear the table buffer by assigning null.

Solution:

i was inserting the records through code in multiple companies using the same table buffer and i had to assign null to the table buffer after switching the company to resolve this issue as it was not assigning the buffer to null as expected.

LedgerJournalTrans ledgerJournalTrans;

changecompany(company)
{
// nulling
ledgerJournalTrans = null;
ledgerJournalTable = null;
// nulling
ttsbegin;

if(this.parmLedgerJournalTable().RecId)
{
tmpLedgerJournalPost.JournalNum = this.parmLedgerJournalTable().JournalNum;
tmpLedgerJournalPost.Branch = ledgerTransactionVoucher.Branch;
tmpLedgerJournalPost.VoucherType= ledgerTransactionVoucher.VoucherType;
tmpLedgerJournalPost.TransDate = ledgerTransactionVoucher.TransDate;
tmpLedgerJournalPost.Company = ledgerTransactionVoucher.Company;
tmpLedgerJournalPost.insert();
}
//further operations
}

Happy Daxing  🙂

Advertisements
 

Tags: , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: