table.setconnection()

hi friends,

i am using table.setconnection(userconnection), for one company it hang the Ax, could you please tell me what would be the probable reasons.

here is the code:

numbersequencetable numberSequenceTable;
UserConnection userConnection;
;

userConnection = new Connection();

userConnection.ttsbegin();
numberSequenceTable.setConnection(userConnection);

select firstonly forupdate numberSequenceTable
index hint SeriesIdx
where numberSequenceTable.NumberSequence == ‘Voor_94’;

info(strfmt(’%1’,numberSequenceTable.RecId));

userConnection.ttscommit();

The most likely explanation is that the record is locked. You select the record for update and NumberSequenceTable uses pessimistic locking, therefore AX wants to obtain a lock. If it’s already locked, the request must wait. If your code never releases the original lock, it will wait forever.

By the way, what are you trying to do with setConnection()? Your code snippet doesn’t do anything useful.

Thanks,

but this happens with single company and working fine for rest.

Maybe the code that locks the record works in that way. Don’t speculate - when it gets stuck, check locks in SQL Server to see what’s happening there.

is there any other way to remove the other connection to that table so that lock will be free