Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Codeunit to update shipping agent and agent service

Posted on by Microsoft Employee

Hi,

I am trying to update the "Shipping Agent Service Code" and "Shipping Agent Code" fields of a sales order. I created a code unit and exposed it to a web service that i call from an external dashboard. The following code does not error out but also does not update either field. How can I go about doing this?? The web service and code unit both work since i have multiple other procedures that work perfectly fine. 

*Note:

id: System id of the sales order

agent: The agent code

    procedure EditShippingAgent(id: Text; agent: Text): Text
    var
        so: Record "Sales Header";
        soObj: Codeunit "Sales Orders";
    begin
        if so.GetBySystemId(id) then begin
            // so."Shipping Agent Code" := agent;
            so."Shipping Agent Service Code" := agent;
            exit(soObj.getHeaderPage(id, ''));
        end;
        exit('{value:{SO_Not_Found:"true"}}');
    end;

Categories:
  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 Moderator on at
    RE: Codeunit to update shipping agent and agent service

    You need to put in a so.modify(true);  after line 8. Or else your change will not be saved to the database.

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,564 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,651 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans