Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

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

Posted on by Microsoft Employee

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

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Inbound Order throws error : Code must have a value in Order Lines

    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.

  • keoma Profile Picture
    keoma 32,675 on at
    RE: Inbound Order throws error : Code must have a value in Order Lines

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Inbound Order throws error : Code must have a value in Order Lines

    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?

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Inbound Order throws error : Code must have a value in Order Lines

    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.

  • Suggested answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: Inbound Order throws error : Code must have a value in Order Lines

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans