deadlock issues with Nav

Good Day

we are having an issue with deadlocking on Nav primarily on the Sales Price object, like 60+ a day.

is there anyway to help prevent this?


Are these two processes running the same code?

not really but they do seem very similar

this is SPID114

this is SPID 104

With 'same code" I meant C/AL code. [H]

Sorry I am still relatively new to this, where would i check this?

In C/SIDE (i.e. development environment of NAV).

Question: who is managing the NAV application code your company is using?

Our Developer Kevin, is there anything you would like to know? other than if the 2 processes used the same code.

Not for now.

Hey Luc,

The only code posting into the sales price table is from the sales price worksheet, other than that there is nothing else that inserts into that table.

The Pages reading Data from this table are the “Sales Orders” page and the “Credit Notes” Page.

this is the C/AL for the sales price



IF “Sales Type” = “Sales Type”::“All Customers” THEN

“Sales Code” := ‘’


TESTFIELD(“Sales Code”);

TESTFIELD(“Item No.”);




IF “Sales Type” <> “Sales Type”::“All Customers” THEN

TESTFIELD(“Sales Code”);

TESTFIELD(“Item No.”);

Item No. - OnValidate()

IF “Item No.” <> xRec.“Item No.” THEN BEGIN

Item.GET(“Item No.”);

“Unit of Measure Code” := Item.“Sales Unit of Measure”;

“Variant Code” := ‘’;


IF “Sales Type” = “Sales Type”::“Customer Price Group” THEN

IF CustPriceGr.GET(“Sales Code”) AND

(CustPriceGr.“Allow Invoice Disc.” = “Allow Invoice Disc.”)




Item No. - OnLookup()

Sales Code - OnValidate()

IF “Sales Code” <> ‘’ THEN

CASE “Sales Type” OF

“Sales Type”::“All Customers”:

ERROR(Text001,FIELDCAPTION(“Sales Code”));

“Sales Type”::“Customer Price Group”:


CustPriceGr.GET(“Sales Code”);

//“Price Includes VAT” := CustPriceGr.“Price Includes VAT”;

“VAT Bus. Posting Gr. (Price)” := CustPriceGr.“VAT Bus. Posting Gr. (Price)”;

“Allow Line Disc.” := CustPriceGr.“Allow Line Disc.”;

“Allow Invoice Disc.” := CustPriceGr.“Allow Invoice Disc.”;


“Sales Type”::Customer:


Cust.GET(“Sales Code”);

“Currency Code” := Cust.“Currency Code”;

//“Price Includes VAT” := Cust.“Prices Including VAT”;

“VAT Bus. Posting Gr. (Price)” := Cust.“VAT Bus. Posting Group”;

“Allow Line Disc.” := Cust.“Allow Line Disc.”;


“Sales Type”::Campaign:


Campaign.GET(“Sales Code”);

“Starting Date” := Campaign.“Starting Date”;

“Ending Date” := Campaign.“Ending Date”;



Sales Code - OnLookup()

Currency Code - OnValidate()

Currency Code - OnLookup()

Starting Date - OnValidate()

IF (“Starting Date” > “Ending Date”) AND (“Ending Date” <> 0D) THEN

ERROR(Text000,FIELDCAPTION(“Starting Date”),FIELDCAPTION(“Ending Date”));

IF CurrFieldNo = 0 THEN


IF “Starting Date” <> 0D THEN

IF “Sales Type” = “Sales Type”::Campaign THEN

ERROR(Text002,“Sales Type”);

Starting Date - OnLookup()

Unit Price - OnValidate()

Unit Price - OnLookup()

Price Includes VAT - OnValidate()

Price Includes VAT - OnLookup()

Allow Invoice Disc. - OnValidate()

Allow Invoice Disc. - OnLookup()

VAT Bus. Posting Gr. (Price) - OnValidate()

VAT Bus. Posting Gr. (Price) - OnLookup()

Sales Type - OnValidate()

IF “Sales Type” <> xRec.“Sales Type” THEN BEGIN

VALIDATE(“Sales Code”,’’);



Sales Type - OnLookup()

Minimum Quantity - OnValidate()

Minimum Quantity - OnLookup()

Ending Date - OnValidate()

IF CurrFieldNo = 0 THEN


VALIDATE(“Starting Date”);

IF “Ending Date” <> 0D THEN

IF “Sales Type” = “Sales Type”::Campaign THEN

ERROR(Text002,“Sales Type”);

Ending Date - OnLookup()

Unit of Measure Code - OnValidate()

Unit of Measure Code - OnLookup()

Variant Code - OnValidate()

Variant Code - OnLookup()

Allow Line Disc. - OnValidate()

Allow Line Disc. - OnLookup()

Sales Description - OnValidate()

Sales Description - OnLookup()

Market - OnValidate()

Market - OnLookup()

Deal Details - OnValidate()

Deal Details - OnLookup()

Created Date - OnValidate()

Created Date - OnLookup()

Deal Type - OnValidate()

Deal Type - OnLookup()

Comments - OnValidate()

Comments - OnLookup()

Item Description - OnValidate()

Item Description - OnLookup()

ID - OnValidate()

ID - OnLookup()

LOCAL UpdateValuesFromItem()

IF Item.GET(“Item No.”) THEN BEGIN

“Allow Invoice Disc.” := Item.“Allow Invoice Disc.”;

IF “Sales Type” = “Sales Type”::“All Customers” THEN BEGIN

“Price Includes VAT” := Item.“Price Includes VAT”;

“VAT Bus. Posting Gr. (Price)” := Item.“VAT Bus. Posting Gr. (Price)”;



Let me ask it differently. What are these two users/processes doing when the deadlock occurs?

We believe it is when they create sales orders and credit notes/Insert new data into the sales price table

With “believe” you will not get to a solution. You have to be sure what is being done before the deadlock occurs.


From the code and customization we have determined it to be the create sales orders and credit notes; however the guys experiencing the issue are creating orders and sometimes its the credit notes.


Beon Smal

Would like to add that - I’ve only seen the screenshots on the New - Sales order page