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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Codeunit to update shipping agent and agent service

(0) ShareShare
ReportReport
Posted on by

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;

I have the same question (0)
  • Suggested answer
    IB-29041624-0 Profile Picture
    1,191 Moderator on at

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 566 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 347 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 327 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans