web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

DeleteALL function caused ErrorCode:NDBCS:LockTimeout

(0) ShareShare
ReportReport
Posted on by

Hi Expert,

I write a codeunit A with procedure B, for procedure B, I need to get specific posted sales shipment line, I also create a table C to store Posted sales Shipment line data, below is my table definition:

 fields
    {
        field(1; itemID; Code[30])
        {
            DataClassification = CustomerContent;
        }

        field(2; remainQTY; Integer)
        {
            DataClassification = CustomerContent;
        }
        field(3; weight; Decimal)
        {
            DataClassification = CustomerContent;
        }
        field(4valueDecimal)
        {
            DataClassification = CustomerContent;
        }
        field(5; UOM; code[10])
        {
            DataClassification = CustomerContent;
        }
        field(6; description; text[128])
        {
            DataClassification = CustomerContent;
        }
        field(7; Lot; Code[128])
        {
            FieldClass = FlowField;
            CalcFormula = Lookup (item."Lot Nos." Where("No." = Field(itemID)));

        }
        field(8; Serial; Code[128])
        {
            FieldClass = FlowField;
            CalcFormula = Lookup (item."Serial Nos." Where("No." = Field(itemID)));

        }
        field(9; lineNumber; Integer)
        {
            DataClassification = CustomerContent;
        }
    }

Before I insert table "Sales Shipment Line" data to table C, I try to deleteAll data in table C:

var

c : record C

begin

c.DeleteAll();

//insert data

end;

When I run this D365BC cloud environment, it error out:

ErrorCode:NDBCS:LockTimeout

StackTrace:

     at Microsoft.Dynamics.Nav.Runtime.RecordImplementationHelper.MapException(NavCSideException originalException, NavDatabase database, Int32 companyToken, NCLMetaTable metaTable, IRecordBuffer recordBuffer, Boolean makeNewExceptionRemappable) in s:\repo\src\Platform\Server\Prod.Ncl\Data\RecordImplementationHelper.cs:line 909

     at Microsoft.Dynamics.Nav.Runtime.RecordImplementation.MapException(NavCSideException exception, IRecordBuffer recordBuffer, Boolean makeNewExceptionRemappable) in s:\repo\src\Platform\Server\Prod.Ncl\Data\RecordImplementation.cs:line 3453

     at Microsoft.Dynamics.Nav.Runtime.RecordImplementation.DeleteAllRecords() in s:\repo\src\Platform\Server\Prod.Ncl\Data\RecordImplementation.cs:line 3672

     at Microsoft.Dynamics.Nav.Runtime.NavRecord.DeleteAll(Boolean runApplicationTrigger) in s:\repo\src\Platform\Server\Prod.Ncl\Runtime\NavRecord.cs:line 330

     at Microsoft.Dynamics.Nav.BusinessApplication.CodeunitA.GetItem_Scope_962805188.OnRun()

     at Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run() in s:\repo\src\Platform\Server\Prod.Ncl\Runtime\NavMethodScope.cs:line 456

     at Microsoft.Dynamics.Nav.BusinessApplication.CodeunitA.GetItem(NavCode shipmentNum, NavText packageorAuto)

     at Microsoft.Dynamics.Nav.BusinessApplication.CodeunitA.OnInvoke(Int32 memberId, Object[] args)

Could anyone shed me some lights on it? what is the probably reason caused this issue?

Thanks,

Ming

     

  • Verified answer
    THE Italian Profile Picture
    Microsoft Employee on at

    There are some special concerns.

    First check. I would try to perform the DELETALL per se, to see if there are some exotic extension that would prevent this to happen. If this works, then the refactor proposed in the check might fit your needs. If it does not, I would try to get more information using a loop of records with DELETE (I know it is costly but it could have more insights).

    Second check. Be sure that your object where you specifiy the DELETEALL has the permisson set in the codeunit object to perform RIMD.

    Third and last. I think that the transaction where your code starts already keep the table locked. At certain point you want to run the DELETEALL that would result in a sort of deadlock. 

    I would rather recommend to refactor your code in order to perform these task in a sequenced order where you first copy everything and once this is performed then you could move forward in delete ALL the records in the table right after.  

    NOTE: even if you succeed to have this object working within a sandbox, I would strongly encourage you also in test this in a foo company in production database since these kind of deletion might have more permissions checks behind the hood.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 715 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 452 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 371 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans