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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Inbound Order throws error : Code must have a value in Order Lines

(0) ShareShare
ReportReport
Posted on by

Hi Nay guys,

I am creating unit test on the basis of web service that is created by exposing NAV page/ code units as Web service.

Now i'm creating unit test on inbound order below is the code for the same:

 InboundOrder.InboundOrder_PortClient ioClient = new InboundOrder.InboundOrder_PortClient();
                InboundOrder.InboundOrder newIO = new InboundOrder.InboundOrder();

                ioClient.Create(ref newIO);
                newIO.Customer_No = "ICOC000001";
                newIO.Master_Transport_Contract = "ICOM000096";
                newIO.Order_Type = "NORMAL";
                newIO.Order_Date = DateTime.Now;
                newIO.Goods_Status = InboundOrder.Goods_Status.Container;
                newIO.Location_code = "ZA-SITE";
                newIO.WMS_Warehouse = "ZA-WH";
                newIO.Loading_Date = DateTime.Now;
                newIO.Unloading_Date = DateTime.Now.AddDays(1);
                ioClient.Update(ref newIO);

                newIO.sfOrderLines = new InboundOrder.WMS_Inbound_Order_Lines[1];
                newIO.sfOrderLines[0] = new InboundOrder.WMS_Inbound_Order_Lines();

                //ioClient.Update(ref newIO);

                var orderLines = newIO.sfOrderLines[0];
                orderLines.Line_Type = InboundOrder.Line_Type.Item;
                orderLines.Code = "ICOSKU00000000000002";
                orderLines.Productcode = "VEHICLE TYRES";
                orderLines.Variant = "GOODYEAR";
                orderLines.Description = "Vehicle Tyres";
                orderLines.Quantity = 500;
                orderLines.Unit_of_measure = "EA";
                orderLines.Quantity_Base = 200;
                orderLines.Weight = 1000;
                ioClient.Update(ref newIO); // error occures here


the error screenshot is attached below 

2804.Capture1.PNG

while updating order line it encounter some error below

Error message is 

Code must have a value in Order Lines: Type=Inbound Order, Internal Document No.=ICOIB00038, Line No.=10000. It cannot be zero or empty.

even supplied code. please suggest me any workaround to avoid this issue.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    keoma Profile Picture
    32,729 on at

    check if the given value in

    orderLines.Code = "ICOSKU00000000000002"

    is valid.

    it seems, that the value is validated, when saving to database and throws that error, because the value was not found.

    does the code field has a tablerelation? if yes, check in that table if the value exists. also check the field onvalidate trigger.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,247 Super User 2025 Season 2 on at

    What is the Page No. you published ? I think there is a validation on the modify trigger of that table which i believe is clearing you code value and causing the issue, check if there are any validations or checks being made to clear the Code value on the modify trigger of that table.

    I believe this is a customization.

  • Community Member Profile Picture
    on at

    Page ID: 2027976, I published. I have checked on the orderlines table there are lot of  validations are built upon Code field, but i'm not aware how these validations are impacting the code empty. is there any workaround for this?

  • keoma Profile Picture
    32,729 on at

    how is the code value set in the page ? manually or automatically e.g. when an other value is filled? is there a tablerelation on the code field  or is it a flowfield ?

    please publish the relevant parts of the onmodify trigger and the code-onvalidate trigger of table inbound order line.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,247 Super User 2025 Season 2 on at

    Zishan,

    You need to find the code or modify the code in the table or Page, for testing comment all the code in the modify trigger of the table and page and see if that resolves.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans