Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Order's Line Item didn't Shipped

Posted on by 40


Hi

I used the API https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/api/dynamics_salesorderline_update  to fulfill a line item of an order,
updated shipQuantity, and invoiceQuantity, and got an Ok response, but I see the ShippedQuantity is still empty. what is the reason for that, do I have to make another API Call for this?

I also noticed this ShippedQuantity is a read-only field, we can't set this value


Thanks in advance!


pastedimage1640788379284v1.png

Categories:
  • Khungersumit Profile Picture
    Khungersumit 40 on at
    RE: Order's Line Item didn't Shipped

    Thanks, Inge M. Bruvik

    I am following you now atTwitter :)

  • Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 Moderator on at
    RE: Order's Line Item didn't Shipped

    I am happy to hear that it finally works. And you know where to go if you get into any issues with the credit memos. The community is more than happy to try to help you.

  • Khungersumit Profile Picture
    Khungersumit 40 on at
    RE: Order's Line Item didn't Shipped

    Hi
    Inge M. Bruvik

    Wahoo, It finally worked.
    Thank you so much  

    Now My next hurdle would be of Return, creating a credit memo of line items of an order. I will have to explore how it works.
    I hope I will not get any issues with the same  


    Thanks again

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 Moderator on at
    RE: Order's Line Item didn't Shipped

    Hi,

    I thought this looked good. Only posting seems to be missing here now.

    So if you do posting now either from the bound action in the API or manually in GUI you should get the expected result. Only the second item line on each order should be posted.

    So go for a posting and lets see what happens. I have faith 

  • Khungersumit Profile Picture
    Khungersumit 40 on at
    RE: Order's Line Item didn't Shipped

    Hi 
    Inge M. Bruvik

    I followed the same now. 
    My order has 2 articles.
    I fulfilled 1 set  shipQuantity = 1  and API response was Success, Ok
    I fulfilled 2nd with shipQuantity = 0  and API response was Success, OK

    Before
    pastedimage1641460412537v1.png

    After 
    pastedimage1641460460689v2.png

    2nd Case
    with the new order (with 2 articles), I set both shipQuantity and invoiceQuantity=1  for 1st article, and for 2nd article, I set both shipQuantity and invoiceQuantity=0 
    I get Sucess, Ok response for both.
    and here is what I can see in my Order at UI. 

    pastedimage1641461184805v3.png

    What do you think I have missed here?

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 Moderator on at
    RE: Order's Line Item didn't Shipped

    Maybe it is me who have been a bit unclear or i do not completely understand you.

    For all lines that you do not want to post shipment for the shipQuantity needs to be set to zero (0)

    The same goes for the invoiceQuantity. All lines that you do not want to invoice must have invoiceQuantity set to zero (O).

    So how do the order lines look after you have set the shipQuantity and invoiceQuantity

    If you wanted to only to shipment and what happen is that invoice is being posted then the quantity to invoice must have had a value other than zero in the sales order the same goes for shipping.

    If lines you did not want to ship was shipped it can only happen if the quantity to ship is larger than zero on the sales line.

    Show how do the sales lines look after you have set the quantity but before you do the post?

    I hope this make sense to you ?

  • Khungersumit Profile Picture
    Khungersumit 40 on at
    RE: Order's Line Item didn't Shipped

    Hi Inge M. Bruvik
    Happy New Year! 

    I tried what you suggested but I guess there is some issue.
    When I did step1 and then step3 the whole order was posted and moved to the Sales Invoice section. but I fulfilled only 1 article out of 2. but this is not a Partial Fulfillment CASE
    pastedimage1641376760418v2.png


    and for following which API would you suggest for the POSTING, I used this API => /companies({company_id})/salesOrders({salesOrder_id})/Microsoft.NAV.shipAndInvoice
    pastedimage1641376889256v3.png




  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 Moderator on at
    RE: Order's Line Item didn't Shipped

    Hi again,

    I understand your confusion because i was using the field names that you see in the Business Central GUI and not the field names that is used in the api.

    So the quantity field in the API is the ordered quantity - like the quantity the customer ordered.

    "invoiceQuantity": "decimal",
    "shipQuantity": "decimal",

    These are the fields that you will use to set the quantity you want to ship and the quantity you want to invoice in this posting. So you set those fields and then you do the posting.

    "shippedQuantity": "decimal",
    "invoicedQuantity": "decimal",

    Are updated after posting and will show the total quantity shipped and total quantity invoiced. And the numbers you find in these two fields can be the result of one or more postings.

    When it comes to the shipment tracking it looks like Microsoft did not include that in any of their standard API's.

    So for this we should implement a custom API. And for that we need to develop a custom API page.
    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-develop-custom-api

    Here is a code sample for how you can implement that custom api in Business Central

    page 50101 SalesHeaderCustomApi
    {
       
        APIGroup = 'SalesHead';
        APIPublisher = 'NorthW';
        APIVersion = 'v1.0';
        Caption = 'salesHeaderCustomApi';
        DelayedInsert = true;
        EntityName = 'salesHead';
        EntitySetName = 'salesHeads';
        PageType = API;
        SourceTable = "Sales Header";
       
        layout
        {
            area(content)
            {
                repeater(General)
                {
                    field(transportMethod; Rec."Transport Method")
                    {
                        Caption = 'Transport Method';
                    }
                    field(packageTrackingNo; Rec."Package Tracking No.")
                    {
                        Caption = 'Package Tracking No.';
                    }
                    field(shipmentMethodCode; Rec."Shipment Method Code")
                    {
                        Caption = 'Shipment Method Code';
                    }
                    field(shippingAdvice; Rec."Shipping Advice")
                    {
                        Caption = 'Shipping Advice';
                    }
                    field(shippingAgentCode; Rec."Shipping Agent Code")
                    {
                        Caption = 'Shipping Agent Code';
                    }
                    field(shippingAgentServiceCode; Rec."Shipping Agent Service Code")
                    {
                        Caption = 'Shipping Agent Service Code';
                    }
                }
            }
        }
       
    }
    I added the relevant shipping fields - you may not have to use all of them but i added them while i was at it.
    If you are not the one doing the AL development you can hand this to the AL developers and tell them you need a custom API like this implemented in order to be able to update the tracking information.
    Hope this helps you further.

     

  • Khungersumit Profile Picture
    Khungersumit 40 on at
    RE: Order's Line Item didn't Shipped

    Hi Inge M. Bruvik
    Thanks for the detailed explanation. Really appreciate your time 
     
    Can you please check these :)
    For the 3rd query: You suggested the following but I couldn't find any such "Package Tracking No" field or similar on the APIs (https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/api/dynamics_salesorder_update)
    , Can you please share the API reference for this "Package Tracking No" field?

    • You can update the field "Package Tracking No" on the sales order before you run the bounded SHIPANDINVOICE. Then you can use the sales order API.


    from 1st query, you have suggested a couple of times already sorry I didn't get this. We have these 2 fields for Quantity, can you please tell which is qty. to ship field you were referencing is it quantity (If I am not wrong this is the ordered Quantity we shouldn't set this?) or shipQuantity? (https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/api/dynamics_salesorderline_update)

                       
    Update all the lines you want to ship with the qty. to ship

    pastedimage1640933932920v1.png











  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 Moderator on at
    RE: Order's Line Item didn't Shipped

    I will try to be be a bit clearer then.

    The process of creating a shipment in Business Central is a two step process..

    First you have to set the qty. you want to ship on the Sales order lines you want to ship. For that purpose you use the field "Qty. to ship".

    In order to do perform the actual shipment you have to do an action called "Post" that process will draw the items from your inventory, create a posted shipment document in Business Central and it will update the Qty. shipped field on your sales lines. You can not update the Qty. shipped field on your sales lines directly. That update is a system process that is done as a result of you posting the shipment.

    And for doing the "post" action you have to use the bound action SHIPANDINVOICE that i mentioned in the previous post.

    So in your scenarios the steps you have to go through is:

    1) Partial

    • Update all the lines you want to ship with the qty. to ship
    • If you want to invoice you also need to update the qty. to invoice. If you don't want to invoice. Qty. to invoice should be set to zero
    • Run the bound action SHIPANINVOICE on the sales order

    2) full order

    • Update all the lines you want to ship with the qty. to ship. In this case it will be all the lines on your salesorder
    • If you want to invoice you also need to update the qty. to invoice. If you don't want to invoice. Qty. to invoice should be set to zero
    • Run the bound action SHIPANINVOICE on the sales order

    3)  Tracking information

    So it is important to understand that you can not update the shipped qty directly on the sales line. You need to do the post action to actually fulfill your shipment in Business Central.

    Did that make it any clearer?

    I am sorry i did not find any good complete examples to share with you that shows you the steps in code.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,645 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans