<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Carlton Moseti on Medium]]></title>
        <description><![CDATA[Stories by Carlton Moseti on Medium]]></description>
        <link>https://medium.com/@carmoseti?source=rss-89ff1c016962------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Bqljg2Q8B8JMhAiFLOXP2Q.jpeg</url>
            <title>Stories by Carlton Moseti on Medium</title>
            <link>https://medium.com/@carmoseti?source=rss-89ff1c016962------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:57:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@carmoseti/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[MB-820 Series: Web Services — Vehicle Management(REST)]]></title>
            <link>https://medium.com/@carmoseti/mb-820-series-web-services-vehicle-management-rest-2558b481c110?source=rss-89ff1c016962------2</link>
            <guid isPermaLink="false">https://medium.com/p/2558b481c110</guid>
            <category><![CDATA[business-central]]></category>
            <category><![CDATA[dynamics-365]]></category>
            <category><![CDATA[microsoft-navision]]></category>
            <category><![CDATA[microsoft-dynamics-365]]></category>
            <category><![CDATA[mb-820]]></category>
            <dc:creator><![CDATA[Carlton Moseti]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 13:31:08 GMT</pubDate>
            <atom:updated>2025-06-02T13:31:08.856Z</atom:updated>
            <content:encoded><![CDATA[<h3>MB-820 Series: Web Services — Vehicle Management(REST)</h3><h3>Get started on the MB-820 tutorial series</h3><p>The article below is part of a series of articles for the MB-820 tutorials. Click the link below to get started..</p><p><a href="https://medium.com/@carmoseti/mb-820-series-mastering-al-programming-for-microsoft-dynamics-business-central-e4025023dcde">MB-820 Series: Mastering AL Programming for Microsoft Dynamics Business Central</a></p><h3>Web Services (REST) — Setup and Definition</h3><p>Apart from SOAP web services, we can also create and publish functionality as REST API web services for reading and/or writing data back to Business Central.</p><p>Pages of the type API are used to create versioned, webhook-supported, OData v4 enabled REST web services. This type of page can’t be displayed in the user interface, but is intended for building reliable integration services. When creating this page type, one must specify many properties that provide information for the web service endpoint. We’ll use the snippet <strong><em>tpage — Page</em></strong> of type <strong>API</strong> to get the right template and the list of these properties automatically filled in.</p><ul><li><a href="https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-api-pagetype">API page type - Business Central</a></li><li><a href="https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-develop-custom-api">Developing a custom API - Business Central</a></li></ul><p>We will define and test 2 REST API services:</p><ol><li>Vehicle Types API</li><li>Vehicle Register API</li></ol><h3>Define API Page — Vehicle Types API</h3><ol><li>Right click on the space below the <strong>.app</strong> file and click on the first menu option <strong><em>New AL File Wizard (AZ AL Dev Tools)</em></strong></li><li>You will be prompted to <strong>Select Wizard Type</strong>. Type the word <strong><em>Page</em></strong> then hit ENTER</li><li>On the wizard, We will define a new API Page object: <strong>Vehicle Types API</strong> as shown below. Once done click finish:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*yTQc9iD0zefFEAaoehC_mQ.png" /><figcaption>Vehicle Types API Page properties</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*skoNFKMUzGYiov2M2yAaxg.png" /><figcaption>Vehicle Types API Page fields</figcaption></figure><ul><li>We see that a new file <strong>Pag50110.VehicleTypesAPI.al</strong> is created.</li></ul><p>4. We will modify/add some properties to the file as follows:</p><ul><li>Caption = ‘Vehicle Types API’;</li><li>EntityCaption = ‘Vehicle Type’;</li><li>EntitySetCaption = ‘Vehicle Types’;</li><li>ODataKeyFields = SystemId;</li></ul><pre>...<br><br>Caption = &#39;Vehicle Types API&#39;;<br>EntityCaption = &#39;Vehicle Type&#39;;<br>EntitySetCaption = &#39;Vehicle Types&#39;;<br>ODataKeyFields = SystemId;<br><br>...</pre><p>5. Add field systemId to the page field list below the <strong>parentNo</strong> field</p><pre>...<br><br>field(systemId; Rec.SystemId)<br>{<br>    Caption = &#39;System Id&#39;;<br>}<br><br>...</pre><p>6. The complete file should be as follows:</p><pre>page 50110 &quot;Vehicle Types API&quot;<br>{<br>    APIGroup = &#39;vehicleManagement&#39;;<br>    APIPublisher = &#39;vehiclePublisher&#39;;<br>    APIVersion = &#39;v1.0&#39;;<br>    ApplicationArea = All;<br>    Caption = &#39;Vehicle Types API&#39;;<br>    DelayedInsert = true;<br>    EntityName = &#39;vehicleType&#39;;<br>    EntitySetName = &#39;vehicleTypes&#39;;<br>    PageType = API;<br>    SourceTable = &quot;Vehicle Types&quot;;<br><br>    EntityCaption = &#39;Vehicle Type&#39;;<br>    EntitySetCaption = &#39;Vehicle Types&#39;;<br>    ODataKeyFields = SystemId;<br><br>    layout<br>    {<br>        area(Content)<br>        {<br>            repeater(General)<br>            {<br>                field(no; Rec.&quot;No.&quot;)<br>                {<br>                    Caption = &#39;No.&#39;;<br>                }<br>                field(brandName; Rec.&quot;Brand Name&quot;)<br>                {<br>                    Caption = &#39;Brand Name&#39;;<br>                }<br>                field(description; Rec.Description)<br>                {<br>                    Caption = &#39;Description&#39;;<br>                }<br>                field(logoImage; Rec.&quot;Logo/Image&quot;)<br>                {<br>                    Caption = &#39;Logo/Image&#39;;<br>                }<br>                field(parentNo; Rec.&quot;Parent No.&quot;)<br>                {<br>                    Caption = &#39;Parent No.&#39;;<br>                }<br>                field(systemId; Rec.SystemId)<br>                {<br>                    Caption = &#39;System Id&#39;;<br>                }<br>            }<br>        }<br>    }<br>}</pre><p>7. Save the file and publish your changes.</p><h3>Publish API — Vehicle Types API</h3><ol><li>On the Business Central top right menu, click the Search icon, then search for the list page <strong>Web Services</strong>. Click on the Web Services item to open the list page.</li><li>Click on the <strong>+ New</strong> button to define our <strong>“Vehicle Types API”</strong>. You will see a new row item is added to our web services list. Proceed to input as follows:</li></ol><ul><li>Object Type = <strong><em>Page</em></strong></li><li>Object Id = <strong><em>50110</em></strong> (The number of the Vehicle Types API Page)</li><li>After typing the Object Id value, press TAB key. You will see that the <strong>Object Name</strong> field is autocompleted for you.</li><li>Service Name = <strong><em>VehicleTypesAPI</em></strong></li><li>Published = <strong><em>true</em></strong></li><li>Press TAB key. You will see that the <strong>SOAP URL</strong> and <strong>OData V4 URL</strong> fields are populated with a link.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ugcLYGGeIC4pUmv68j9pGQ.png" /></figure><p>3. Click the <strong>OData V4 URL</strong> link provided:</p><ul><li>A new tab will be opened whereby you will be prompted to login.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*nnC3486TbY1lVAj9tckRsg.png" /></figure><ul><li>Login with your Business Central user account credentials. Once logged in successfully, we are presented with an OData JSON response on the browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*e7XXflwLMvYK1c3GqsHBDA.png" /></figure><p>4. The JSON response is a list of <strong>Vehicle Types</strong> from the database.</p><h3>Setup Postman Collection</h3><p>We will use Postman to test our API. Ensure you have your OData V4 URL value. E.g. <a href="http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(&#39;CRONUS%20International%20Ltd.&#39;)/VehicleTypesAPI">http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(‘CRONUS%20International%20Ltd.’)/VehicleTypesAPI</a></p><ol><li>Navigate to Postman and create a new collection <strong>Vehicle Management REST Service</strong></li><li>Define new variables for the collection as follows:</li></ol><ul><li><strong>rest_base_url</strong> = <strong><em>&lt;YOUR REST BASE URL&gt;</em></strong> e.g. <a href="http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(&#39;CRONUS%20International%20Ltd">http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(‘CRONUS%20International%20Ltd</a>.’)</li><li><strong>ntlm_username</strong> = <strong><em>&lt;YOUR BC USERNAME&gt;</em></strong> e.g. Administrator</li><li><strong>ntlm_password</strong> = <strong><em>&lt;YOUR BC PASSWORD&gt;</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*SSh9DN1uykd9b7PJTJwrXA.png" /></figure><p>3. Click on the <strong>Authorization</strong> tab to define the NTLM authentication credentials for reaching the REST service.</p><ul><li>Select <strong>Auth Type</strong> = <strong><em>NTLM Authentication</em></strong></li><li>Username = <strong>{{ntlm_username}}</strong></li><li>Password = <strong>{{ntlm_password}}</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*b_bqacaFm_PZUP-WZLH2sQ.png" /></figure><p>4. We will proceed to test the following services:</p><ul><li>Fetching a list of Vehicle Types</li><li>Fetching a single Vehicle Type Details</li><li>Creating a new vehicle type</li><li>Updating a vehicle type</li><li>Deleting a vehicle type</li></ul><h3>Test API — Fetching a list of Vehicle Types</h3><ol><li>On the left sidebar navigation below your collection, click on the link <strong>Add a request</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*Oeqkgboi0pgAgl_T32FnPg.png" /></figure><ul><li>Name the request as <strong><em>Vehicle Types List</em></strong></li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{rest_base_url}}/VehicleTypesAPI</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*yDgzkgDXJStZu5F-VSpCRw.png" /></figure><p>2. Once done, click Send button to make the request. We see a list of Vehicle Types is returned in OData JSON format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gzJDPggqtvHnlkuKWvO4lA.png" /></figure><p>3. We can save the response as a sample SUCCESS response from the API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*FGQmu_ZYeQBDS30kiCR0fw.png" /></figure><h3>Test API — Fetching a single Vehicle Type Details</h3><p>To fetch a single item, we will use the value stored in the field defined in the <strong>ODataKeyFields</strong>. In this case we will use the value of the <strong>systemId</strong> field which we had defined as the <strong>ODataKeyFields</strong> of our API.</p><p>The URL syntax is as follows: <a href="http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(&#39;CRONUS%20International%20Ltd.&#39;)/VehicleTypesAPI("><strong><em>http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(‘CRONUS%20International%20Ltd.’)/VehicleTypesAPI(</em></strong></a><strong><em> &lt;ODataKeyFields_Value&gt; )</em></strong></p><p>E.g. if the systemId value is <strong><em>5af22d5e-3ba0-ef11-a0be-000c29c4716e</em></strong> then the URL to fetch the single item is: <a href="http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(&#39;CRONUS%20International%20Ltd.&#39;)/VehicleTypesAPI(5af22d5e-3ba0-ef11-a0be-000c29c4716e)"><strong><em>http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(‘CRONUS%20International%20Ltd.’)/VehicleTypesAPI(5af22d5e-3ba0-ef11-a0be-000c29c4716e)</em></strong></a></p><ol><li>Right click on your collection, then click on the option <strong>Add request</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*MFucDSOGj_7W-sUnUdGSrA.png" /></figure><ul><li>Name the request as <strong><em>Vehicle Type</em></strong></li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{rest_base_url}}/VehicleTypesAPI(5af22d5e-3ba0-ef11-a0be-000c29c4716e)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*YB7_f0vUYBqwqWuVMu17vg.png" /></figure><p>2. Once done, click Send button to make the request. We see a single Vehicle Type item is returned in OData JSON format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*6P06S7fUU77B5Yvz_5enpQ.png" /></figure><p>3. We can save the response as a sample SUCCESS response from the API.</p><h3>Test API — Create a Vehicle Type</h3><ol><li>To create a new <strong>Vehicle Type</strong> we will submit a <strong>POST</strong> request to our OData V4 URL with the JSON body as follows:</li></ol><pre>{<br>    &quot;brandName&quot;: &quot;Jeep&quot;,<br>    &quot;description&quot;: &quot;Jeep Brand&quot;,<br>    &quot;parentNo&quot;: 0<br>}</pre><p>2. Right click on your collection, then click on the option <strong>Add request</strong>.</p><ul><li>Name the request as <strong><em>New Vehicle Type</em></strong></li><li>Change the HTTP method dropdown value from <strong>GET</strong> to <strong>POST</strong>.</li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{rest_base_url}}/VehicleTypesAPI</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*5o0g6XJ4TOmT1N702JeA1A.png" /></figure><p>3. Click on the <strong>Body</strong> tab and configure as follows:</p><ul><li>Choose the body option as <strong>raw</strong>.</li><li>Copy the JSON body request body below.</li></ul><pre>{<br>    &quot;brandName&quot;: &quot;Jeep&quot;,<br>    &quot;description&quot;: &quot;Jeep Brand&quot;,<br>    &quot;parentNo&quot;: 0<br>}</pre><ul><li>Paste the contents on the body section in Postman</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*YVuD6BQKl1RIPXmZYF1-0w.png" /></figure><p>4. Once done, click Send button to make the request. We see a newly created Vehicle Type item is returned in OData JSON format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2zaLskQcec6U4jM9Zj7YYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*y3viDJcrzxeg2NbuirHhgw.png" /></figure><p>5. We can save the response as a sample SUCCESS response from the API.</p><h3>Test API — Modify a Vehicle Type</h3><ol><li>Obtain the <strong>systemId</strong> value of the <strong>Vehicle Type</strong> item that you want to edit. For example:</li></ol><ul><li>systemId = bde43528–0fc2-ef11-a0c0–000c29c4716e</li></ul><p>2. To update an existing <strong>Vehicle Type</strong> we will submit a <strong>PATCH</strong> request to our OData V4 URL with the JSON body as follows:</p><pre>{<br>    &quot;brandName&quot;: &quot;Jeep&quot;,<br>    &quot;description&quot;: &quot;Jeep Brand&quot;,<br>    &quot;parentNo&quot;: 0<br>}</pre><p>3. Right click on your collection, then click on the option <strong>Add request</strong>.</p><ul><li>Name the request as <strong><em>Update Vehicle Type</em></strong></li><li>Change the HTTP method dropdown value from <strong>GET</strong> to <strong>PATCH</strong>.</li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{rest_base_url}}/VehicleTypesAPI(bde43528–0fc2-ef11-a0c0–000c29c4716e)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*UpLmoWjiJAeeU_OgkogCVQ.png" /></figure><p>4. Click on the <strong>Headers</strong> tab and configure as follows:</p><ul><li>Add key <strong>If-Match</strong> with value = *</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*4JT8iXpIq8TO_inZhHCEGQ.png" /></figure><p>5. Click on the <strong>Body</strong> tab and configure as follows:</p><ul><li>Choose the body option as <strong>raw</strong>.</li><li>Copy the JSON body request body below.</li></ul><pre>{<br>    &quot;brandName&quot;: &quot;Jeep&quot;,<br>    &quot;description&quot;: &quot;Jeep Brand Modified&quot;,<br>    &quot;parentNo&quot;: 0<br>}</pre><ul><li>Paste the contents on the body section in Postman</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*69JEWqdiLdjaRy_rIuLwuA.png" /></figure><p>6. Once done, click Send button to make the request. We see the modified Vehicle Type item is returned in OData JSON format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*Osv5WYQl9wh3KPgBpD7ZBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*dS3cu3E1tjkoDNvGv7Y-6w.png" /></figure><p>7. We can save the response as a sample SUCCESS response from the API.</p><h3>Test API — Delete a Vehicle Type</h3><ol><li>Obtain the <strong>systemId</strong> value of the <strong>Vehicle Type</strong> item that you want to delete. For example:</li></ol><ul><li>systemId = bde43528–0fc2-ef11-a0c0–000c29c4716e</li></ul><p>2. To delete an existing <strong>Vehicle Type</strong> we will submit a <strong>DELETE</strong> request to our OData V4 URL.</p><p>3. Right click on your collection, then click on the option <strong>Add request</strong>.</p><ul><li>Name the request as <strong><em>Vehicle Type</em></strong></li><li>Change the HTTP method dropdown value from <strong>GET</strong> to <strong>DELETE</strong>.</li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{rest_base_url}}/VehicleTypesAPI(bde43528–0fc2-ef11-a0c0–000c29c4716e)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*y9VbUpCmSCXvOYvLCfJy4Q.png" /></figure><p>4. Once done, click Send button to make the request. We encounter an error as shown below:</p><pre>{<br>    &quot;error&quot;: {<br>        &quot;code&quot;: &quot;Application_CallbackNotAllowed&quot;,<br>        &quot;message&quot;: &quot;Microsoft Dynamics 365 Business Central Data Services attempted to issue a client callback to show a confirmation dialog box: Are you sure you want to delete this record? (CodeUnit 50100 Global Functions). Client callbacks are not supported on Microsoft Dynamics 365 Business Central Data Services.  CorrelationId:  ad79830b-dd70-4014-b6b7-ca78eb8ae23c.&quot;<br>    }<br>}</pre><ul><li>This error is because of the confirmation dialog box logic on the <strong>OnDelete</strong> trigger of the <strong>“Vehicle Types”</strong> table.</li></ul><p>5. To resolve the error, we will modify the <strong>Cod50100.GlobalFunctions.al</strong> file which contains the <strong>ConfirmRecordDeletion</strong> procedure that is triggered before record deletion. Modify the procedure as follows: <strong><em>(We will use the System.GuiAllowed procedure to check if the current session is through the browser UI)</em></strong></p><pre>...<br><br>    procedure ConfirmRecordDeletion()<br>    var<br>        myInt: Integer;<br>    begin<br>        // Check if the session is executing via the UI. If NOT skip the confirmation check<br>        if System.GuiAllowed then begin<br>            // Confirm to proceed with deletion<br>            if not (Confirm(&#39;Are you sure you want to delete this record?&#39;)) then begin<br>                // Confirm - No<br>                Error(&#39;Record deletion has been cancelled&#39;);<br>            end else begin<br>                // Confirm - Yes<br>                Message(&#39;Record will be deleted!&#39;);<br>            end;<br>        end;<br>    end;<br><br>...</pre><p>6. Save your changes and publish.</p><p>7. Again click Send button to make the request. We get a blank response with http status <strong>204</strong> which indicates successful request without any response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p5WLPIWcNZNFfLuPbykWKQ.png" /></figure><p>8. When you view the <strong>Vehicle Types</strong> list in Business Central, we see that the record was deleted successfully.</p><h3>Test API — Fetch Vehicle Type Logo</h3><p>When fetching details of a specific vehicle type, we see that there are 2 object properties &quot;logoImage@odata.mediaEditLink&quot; and &quot;logoImage@odata.mediaReadLink&quot;. The properties value is a URL link which is used to either fetch/read the image/logo of the vehicle type or update the logo/image value of the vehicle type. We will use the value of &quot;logoImage@odata.mediaReadLink&quot; to obtain the URL for fetching the vehicle type logo/image.</p><pre>{<br>    &quot;@odata.context&quot;: &quot;http://win-dgqlvoicjqf:7048/BC250/ODataV4/$metadata#Company(&#39;CRONUS%20International%20Ltd.&#39;)/VehicleTypesAPI/$entity&quot;,<br>    &quot;@odata.etag&quot;: &quot;W/\&quot;JzIwOzEyNjMyNTYyNzg0MzkxMDIxOTU1MTswMDsn\&quot;&quot;,<br>    &quot;systemId&quot;: &quot;5af22d5e-3ba0-ef11-a0be-000c29c4716e&quot;,<br>    &quot;no&quot;: 1,<br>    &quot;brandName&quot;: &quot;Volkswagen&quot;,<br>    &quot;description&quot;: &quot;Volkswagen Brand&quot;,<br>    &quot;parentNo&quot;: 0,<br>    &quot;logoImage@odata.mediaEditLink&quot;: &quot;http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(&#39;CRONUS%20International%20Ltd.&#39;)/VehicleTypesAPI(5af22d5e-3ba0-ef11-a0be-000c29c4716e)/logoImage&quot;,<br>    &quot;logoImage@odata.mediaReadLink&quot;: &quot;http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(&#39;CRONUS%20International%20Ltd.&#39;)/VehicleTypesAPI(5af22d5e-3ba0-ef11-a0be-000c29c4716e)/logoImage&quot;<br>}</pre><ol><li>Right click on your collection, then click on the option <strong>Add request</strong>.</li></ol><ul><li>Name the request as <strong><em>Vehicle Type Logo/Image</em></strong></li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{rest_base_url}}/VehicleTypesAPI(5af22d5e-3ba0-ef11-a0be-000c29c4716e)/logoImage</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dnyxIsb6t_OdWgRGR-T1kQ.png" /></figure><p>2. Once done, click Send button to make the request. We see the logo/image of the vehicle type is returned in Blob format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eCB7hV7CeMWZbniu4Ch40A.png" /></figure><p>3. We can save the response as a sample SUCCESS response from the API.</p><h3>Test API — Update Vehicle Type Logo</h3><p>When fetching details of a specific vehicle type, we see that there are 2 object properties &quot;logoImage@odata.mediaEditLink&quot; and &quot;logoImage@odata.mediaReadLink&quot;. The properties value is a URL link which is used to either fetch/read the image/logo of the vehicle type or update the logo/image value of the vehicle type. We will use the value of &quot;logoImage@odata.mediaEditLink&quot; to obtain the URL for updating the vehicle type logo/image.</p><pre>{<br>    &quot;@odata.context&quot;: &quot;http://win-dgqlvoicjqf:7048/BC250/ODataV4/$metadata#Company(&#39;CRONUS%20International%20Ltd.&#39;)/VehicleTypesAPI/$entity&quot;,<br>    &quot;@odata.etag&quot;: &quot;W/\&quot;JzIwOzEyNjMyNTYyNzg0MzkxMDIxOTU1MTswMDsn\&quot;&quot;,<br>    &quot;systemId&quot;: &quot;5af22d5e-3ba0-ef11-a0be-000c29c4716e&quot;,<br>    &quot;no&quot;: 1,<br>    &quot;brandName&quot;: &quot;Volkswagen&quot;,<br>    &quot;description&quot;: &quot;Volkswagen Brand&quot;,<br>    &quot;parentNo&quot;: 0,<br>    &quot;logoImage@odata.mediaEditLink&quot;: &quot;http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(&#39;CRONUS%20International%20Ltd.&#39;)/VehicleTypesAPI(5af22d5e-3ba0-ef11-a0be-000c29c4716e)/logoImage&quot;,<br>    &quot;logoImage@odata.mediaReadLink&quot;: &quot;http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(&#39;CRONUS%20International%20Ltd.&#39;)/VehicleTypesAPI(5af22d5e-3ba0-ef11-a0be-000c29c4716e)/logoImage&quot;<br>}</pre><ol><li>Right click on your collection, then click on the option <strong>Add request</strong>.</li></ol><ul><li>Name the request as <strong><em>Update Vehicle Type Logo/Image</em></strong></li><li>Change the HTTP method dropdown value from <strong>GET</strong> to <strong>PUT</strong>.</li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{rest_base_url}}/VehicleTypesAPI(5af22d5e-3ba0-ef11-a0be-000c29c4716e)/logoImage</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QkecZIvKDK5j3YVVTA5GDQ.png" /></figure><p>2. Click on the <strong>Headers</strong> tab and configure as follows:</p><ul><li>Add key <strong>If-Match</strong> with value = *</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*lLFguiUoYqiqqsuSnhn3Sw.png" /></figure><p>3. Click on the <strong>Body</strong> tab and configure as follows:</p><ul><li>Choose the body option as <strong>binary</strong>.</li><li>Click <strong><em>Select File</em></strong> to choose an image file for the new logo you want to update to.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*PrrchlwmBz4XWSk8vQwLNg.png" /></figure><p>4. Confirm the current logo/image of the vehicle type to be updated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*bIqBJhLL_X6sN_SAaXSXAQ.png" /></figure><p>5. Click Send button to make the request. We get a blank response with http status <strong>204</strong> which indicates successful request without any response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_QxmcRF01-Vr_VmuxiaGag.png" /></figure><p>6. Confirm the current logo/image of the vehicle type has been updated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*ZZSK5wLDLxeErURdgwgDXA.png" /></figure><p>7. We can save the response as a sample SUCCESS response from the API.</p><h3>Test API — Delete Vehicle Type Logo</h3><p>To delete/clear the vehicle type logo/image, we’ll just use the update vehicle type logo in the previous section but we will send the request without a file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k4Roei3lrFqnHRvpJWxBdg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*1r8K_AFZ6KjjhDdov8FVMA.png" /></figure><h3>Define API Page — Vehicle Register API</h3><ol><li>Right click on the space below the <strong>.app</strong> file and click on the first menu option <strong><em>New AL File Wizard (AZ AL Dev Tools)</em></strong></li><li>You will be prompted to <strong>Select Wizard Type</strong>. Type the word <strong><em>Page</em></strong> then hit ENTER</li><li>On the wizard, We will define a new API Page object: <strong>Vehicle Register API</strong> as shown below. Once done click finish:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*HS1EQJCWHBjRUxLFXdLWhA.png" /><figcaption>Vehicle Register Page properties</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*FzT7q6R9PMBhY1z950Iclg.png" /><figcaption>Vehicle Register page fields</figcaption></figure><ul><li>We see that a new file <strong>Pag50111.VehicleRegisterAPI.al</strong> is created.</li></ul><p>4. We will modify/add some properties to the file as follows:</p><ul><li>Caption = ‘Vehicle Register API’;</li><li>EntityCaption = ‘Vehicle’;</li><li>EntitySetCaption = ‘Vehicles’;</li><li>ODataKeyFields = SystemId;</li></ul><pre>...<br><br>Caption = &#39;Vehicle Register API&#39;;<br>EntityCaption = &#39;Vehicle&#39;;<br>EntitySetCaption = &#39;Vehicles&#39;;<br>ODataKeyFields = SystemId;<br><br>...</pre><p>5. Add field systemId to the page field list below the <strong>registrationNo</strong> field</p><pre>...<br><br>field(systemId; Rec.SystemId)<br>{<br>    Caption = &#39;System Id&#39;;<br>}<br><br>...</pre><p>6. We’ll also add the field <strong><em>vehicleTypeName</em></strong> to the page field list below the <strong>systemId</strong> field</p><pre>...<br><br>field(vehicleTypeName; Rec.&quot;Vehicle Type Name&quot;)<br>{<br>    Caption = &#39;Vehicle Type Name&#39;;<br>}<br><br>...</pre><p>7. The complete file should be as follows:</p><pre>page 50111 &quot;Vehicle Register API&quot;<br>{<br>    APIGroup = &#39;vehicleManagement&#39;;<br>    APIPublisher = &#39;vehiclePublisher&#39;;<br>    APIVersion = &#39;v1.0&#39;;<br>    ApplicationArea = All;<br>    DelayedInsert = true;<br>    EntityName = &#39;vehicle&#39;;<br>    EntitySetName = &#39;vehicles&#39;;<br>    PageType = API;<br>    SourceTable = &quot;Vehicle Register&quot;;<br><br>    Caption = &#39;Vehicle Register API&#39;;<br>    EntityCaption = &#39;Vehicle&#39;;<br>    EntitySetCaption = &#39;Vehicles&#39;;<br>    ODataKeyFields = SystemId;<br><br>    layout<br>    {<br>        area(Content)<br>        {<br>            repeater(General)<br>            {<br>                field(vehicleTypeNo; Rec.&quot;Vehicle Type No.&quot;)<br>                {<br>                    Caption = &#39;Vehicle Type No.&#39;;<br>                }<br>                field(vehicleTypeName; Rec.&quot;Vehicle Type Name&quot;)<br>                {<br>                    Caption = &#39;Vehicle Type Name&#39;;<br>                }<br>                field(description; Rec.Description)<br>                {<br>                    Caption = &#39;Description&#39;;<br>                }<br>                field(registrationNo; Rec.&quot;Registration No.&quot;)<br>                {<br>                    Caption = &#39;Registration No.&#39;;<br>                }<br>                field(systemId; Rec.SystemId)<br>                {<br>                    Caption = &#39;System Id&#39;;<br>                }<br>            }<br>        }<br>    }<br>}</pre><p>8. Save the file and publish your changes.</p><h3>Publish API — Vehicle Register API</h3><ol><li>On the Business Central top right menu, click the Search icon, then search for the list page <strong>Web Services</strong>. Click on the Web Services item to open the list page.</li><li>Click on the <strong>+ New</strong> button to define our <strong>“Vehicle Register API”</strong>. You will see a new row item is added to our web services list. Proceed to input as follows:</li></ol><ul><li>Object Type = <strong><em>Page</em></strong></li><li>Object Id = <strong><em>50111</em></strong> (The number of the Vehicle Register API Page)</li><li>After typing the Object Id value, press TAB key. You will see that the <strong>Object Name</strong> field is autocompleted for you.</li><li>Service Name = <strong><em>VehicleRegisterAPI</em></strong></li><li>Published = <strong><em>true</em></strong></li><li>Press TAB key. You will see that the <strong>SOAP URL</strong> and <strong>OData V4 URL</strong> fields are populated with a link.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vcjr45_b6jVPo2jJFMxB7w.png" /></figure><p>3. Click the <strong>OData V4 URL</strong> link provided:</p><ul><li>A new tab will be opened whereby you will be prompted to login.</li><li>Login with your Business Central user account credentials. Once logged in successfully, we are presented with an OData JSON response on the browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*gtKN2y-vQEDWHbRKQjN_ew.png" /></figure><p>4. The JSON response is a list of <strong>Vehicle Register</strong> from the database.</p><h3>Setup Postman Collection</h3><p>We will use Postman to test our API. Ensure you have your OData V4 URL value. E.g. <a href="http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(&#39;CRONUS%20International%20Ltd.&#39;)/VehicleTypesAPI">http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(‘CRONUS%20International%20Ltd.’)/VehicleTypesAPI</a></p><ol><li>Navigate to the Postman Collection <strong>Vehicle Management REST Service</strong></li><li>We will proceed to add and test the following services:</li></ol><ul><li>Fetching a list of Vehicles</li><li>Fetching a single Vehicle Details</li><li>Creating a new vehicle</li><li>Updating a vehicle</li><li>Deleting a vehicle</li></ul><h3>Test API — Fetching a list of Vehicles</h3><ol><li>Right click on the collection, then click on the option <strong>Add request</strong>.</li></ol><ul><li>Name the request as <strong><em>Vehicle Register List</em></strong></li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{rest_base_url}}/VehicleRegisterAPI</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*deNI6e4QEQ2sxsrdw3viaw.png" /></figure><p>2. Once done, click Send button to make the request. We see a list of Vehicles is returned in OData JSON format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6W7ET7K-ABtP7o-Mz1_jPw.png" /></figure><p>3. We can save the response as a sample SUCCESS response from the API.</p><h3>Test API — Fetching a single Vehicle Details</h3><p>To fetch a single item, we will use the value stored in the field defined in the <strong>ODataKeyFields</strong>. In this case we will use the value of the <strong>systemId</strong> field which we had defined as the <strong>ODataKeyFields</strong> of our API.</p><p>The URL syntax is as follows: <a href="http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(&#39;CRONUS%20International%20Ltd.&#39;)/VehicleRegisterAPI("><strong><em>http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(‘CRONUS%20International%20Ltd.’)/VehicleRegisterAPI(</em></strong></a><strong><em> &lt;ODataKeyFields_Value&gt; )</em></strong></p><p>E.g. if the systemId value is <strong><em>691fae8e-3ea0-ef11-a0be-000c29c4716e</em></strong> then the URL to fetch the single item is: <a href="http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(&#39;CRONUS%20International%20Ltd.&#39;)/VehicleRegisterAPI(691fae8e-3ea0-ef11-a0be-000c29c4716e)"><strong><em>http://win-dgqlvoicjqf:7048/BC250/ODataV4/Company(‘CRONUS%20International%20Ltd.’)/VehicleRegisterAPI(691fae8e-3ea0-ef11-a0be-000c29c4716e)</em></strong></a></p><ol><li>Right click on your collection, then click on the option <strong>Add request</strong>.</li></ol><ul><li>Name the request as <strong><em>Vehicle Details</em></strong></li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{rest_base_url}}/VehicleRegisterAPI(691fae8e-3ea0-ef11-a0be-000c29c4716e)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*uh28Og7eQq13_tfcfYy_ZQ.png" /></figure><p>2. Once done, click Send button to make the request. We see a single Vehicle item is returned in OData JSON format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BblzvbyiIHXJZ2XRM7sjfQ.png" /></figure><p>3. We can save the response as a sample SUCCESS response from the API.</p><h3>Test API — Create a Vehicle</h3><ol><li>To create a new <strong>Vehicle</strong> we will submit a <strong>POST</strong> request to our OData V4 URL with the JSON body as follows: <strong><em>(We use vehicleTypeNo = 2 which is for Volkswagen Golf)</em></strong></li></ol><pre>{<br>    &quot;vehicleTypeNo&quot;: 2,<br>    &quot;description&quot;: &quot;2025 Red Volkswagen Golf&quot;,<br>    &quot;registrationNo&quot;: &quot;REG998&quot;<br>}</pre><p>2. Right click on your collection, then click on the option <strong>Add request</strong>.</p><ul><li>Name the request as <strong><em>New Vehicle</em></strong></li><li>Change the HTTP method dropdown value from <strong>GET</strong> to <strong>POST</strong>.</li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{rest_base_url}}/VehicleRegisterAPI</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*yxRwVIMahpUqKEctm0-RhA.png" /></figure><p>3. Click on the <strong>Body</strong> tab and configure as follows:</p><ul><li>Choose the body option as <strong>raw</strong>.</li><li>Copy the JSON body request body below.</li></ul><pre>{<br>    &quot;vehicleTypeNo&quot;: 2,<br>    &quot;description&quot;: &quot;2025 Red Volkswagen Golf&quot;,<br>    &quot;registrationNo&quot;: &quot;REG998&quot;<br>}</pre><ul><li>Paste the contents on the body section in Postman</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*WfHsI0ZVgkURu7Ir4KssSA.png" /></figure><p>4. Once done, click Send button to make the request. We see a newly created Vehicle item is returned in OData JSON format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D7sQhXMa6zTliUxLEi3Tkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*A2mAH45oPOkSz5GxCJIMIA.png" /></figure><p>5. We can save the response as a sample SUCCESS response from the API.</p><h3>Test API — Modify a Vehicle</h3><ol><li>Obtain the <strong>systemId</strong> value of the <strong>Vehicle Type</strong> item that you want to edit. For example:</li></ol><ul><li>systemId = f34f3834–60c4-ef11-a0c0–000c29c4716e</li></ul><p>2. To update an existing <strong>Vehicle</strong> we will submit a <strong>PATCH</strong> request to our OData V4 URL with the JSON body as follows:</p><pre>{<br>    &quot;vehicleTypeNo&quot;: 2,<br>    &quot;description&quot;: &quot;2025 Volkswagen Golf, Red Color&quot;,<br>    &quot;registrationNo&quot;: &quot;REG998&quot;<br>}</pre><p>3. Right click on your collection, then click on the option <strong>Add request</strong>.</p><ul><li>Name the request as <strong><em>Update Vehicle</em></strong></li><li>Change the HTTP method dropdown value from <strong>GET</strong> to <strong>PATCH</strong>.</li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{rest_base_url}}/VehicleRegisterAPI(f34f3834–60c4-ef11-a0c0–000c29c4716e)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*YUFIr9zXrRfSL_NpWcO3Vg.png" /></figure><p>4. Click on the <strong>Headers</strong> tab and configure as follows:</p><ul><li>Add key <strong>If-Match</strong> with value = *</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*qD1Uq0dPT2z-utQR7DDOrw.png" /></figure><p>5. Click on the <strong>Body</strong> tab and configure as follows:</p><ul><li>Choose the body option as <strong>raw</strong>.</li><li>Copy the JSON body request body below.</li></ul><pre>{<br>    &quot;vehicleTypeNo&quot;: 2,<br>    &quot;description&quot;: &quot;2025 Volkswagen Golf, Red Color&quot;,<br>    &quot;registrationNo&quot;: &quot;REG998&quot;<br>}</pre><ul><li>Paste the contents on the body section in Postman</li></ul><p>6. Once done, click Send button to make the request. We see the modified Vehicle Type item is returned in OData JSON format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-XjUbpd5dqnWWBmtIs9GsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*Cc34wNHGSOQXrrWDbuZFpQ.png" /></figure><p>7. We can save the response as a sample SUCCESS response from the API.</p><h3>Test API — Delete a Vehicle</h3><ol><li>Obtain the <strong>systemId</strong> value of the <strong>Vehicle</strong> item that you want to delete. For example:</li></ol><ul><li>systemId = f34f3834–60c4-ef11-a0c0–000c29c4716e</li></ul><p>2. To delete an existing <strong>Vehicle</strong> we will submit a <strong>DELETE</strong> request to our OData V4 URL.</p><p>3. Right click on your collection, then click on the option <strong>Add request</strong>.</p><ul><li>Name the request as <strong><em>Vehicle</em></strong></li><li>Change the HTTP method dropdown value from <strong>GET</strong> to <strong>DELETE</strong>.</li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{rest_base_url}}/VehicleRegisterAPI(f34f3834–60c4-ef11-a0c0–000c29c4716e)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oVDaAt2AHeFALhsungVsfw.png" /></figure><p>4. Click Send button to make the request. We get a blank response with http status <strong>204</strong> which indicates successful request without any response.</p><p>5. When you view the <strong>Vehicle Register</strong> list in Business Central, we see that the record was deleted successfully.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2558b481c110" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MB-820 Series: Web Services — Vehicle Management(SOAP) — (Part 3)]]></title>
            <link>https://medium.com/@carmoseti/mb-820-series-web-services-vehicle-management-soap-part-3-cd5104e35083?source=rss-89ff1c016962------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd5104e35083</guid>
            <category><![CDATA[dynamics-365]]></category>
            <category><![CDATA[mb-820]]></category>
            <category><![CDATA[microsoft-dynamics-365]]></category>
            <category><![CDATA[microsoft-navision]]></category>
            <category><![CDATA[business-central]]></category>
            <dc:creator><![CDATA[Carlton Moseti]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 12:26:09 GMT</pubDate>
            <atom:updated>2025-06-02T13:31:33.039Z</atom:updated>
            <content:encoded><![CDATA[<h3>MB-820 Series: Web Services — Vehicle Management(SOAP) — (Part 3)</h3><h3>Get started on the MB-820 tutorial series</h3><p>The article below is part of a series of articles for the MB-820 tutorials. Click the link below to get started..</p><p><a href="https://medium.com/@carmoseti/mb-820-series-mastering-al-programming-for-microsoft-dynamics-business-central-e4025023dcde">MB-820 Series: Mastering AL Programming for Microsoft Dynamics Business Central</a></p><h3>Service 5 — Deleting a specific Vehicle Type</h3><p>We will proceed to define the service on the file as follows:</p><ol><li>Add a new procedure <strong>DeleteVehicleType</strong> with 1 parameter as follows:</li></ol><ul><li>VehicleTypeNo: Integer;</li></ul><pre>procedure DeleteVehicleType(<br>    VehicleTypeNo: Integer<br>)<br>begin<br>    // ...<br>end;</pre><p>2. Modify the <strong>DeleteVehicleType</strong> procedure to define the record update logic as follows:</p><pre>procedure DeleteVehicleType(<br>    VehicleTypeNo: Integer<br>): Text<br>var<br>    ExistingVehicleType: Record &quot;Vehicle Types&quot;;<br>begin<br>    // First Check if the vehicle type exists<br>    ExistingVehicleType.Reset;<br><br>    // Filter using the VehicleNo field<br>    ExistingVehicleType.SetRange(&quot;No.&quot;, VehicleTypeNo);<br><br>    if ExistingVehicleType.FindFirst then begin<br>        // Vehicle has been found<br>        // Delete the Vehicle Type record without running the OnDelete trigger<br>        ExistingVehicleType.Delete(false);<br><br>        // Response message<br>        exit(&#39;Vehicle Type has been deleted successfully&#39;);<br>    end else begin<br>        // Vehicle Type has NOT been found<br>        Error(&#39;Vehicle Type referenced by no. %1 does NOT exist in the records&#39;, VehicleTypeNo);<br>    end;<br>end;</pre><ul><li>Before deleting the vehicle type record, we first search for it in the database table. If it does not exist, an error is thrown.</li><li>If the record exists, the record is deleted.</li></ul><p>3. Save the file and publish the changes</p><h3>Test using SOAP UI</h3><ol><li>Open <strong>SOAP UI</strong> and update the SOAP project <strong>Business Central Vehicle Management Service</strong> definition to add the new service <strong>DeleteVehicleType</strong> we have created.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*MRdo_Fp15hKbiDE9zZf5Bw.png" /></figure><p>2. We will create a sample vehicle type using the <strong>CreateVehicleType</strong> that we will then delete using the <strong>DeleteVehicleType</strong> service.</p><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:veh=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>&lt;veh:CreateVehicleType&gt;<br>    &lt;veh:brandName&gt;TO_DELETE&lt;/veh:brandName&gt;<br>    &lt;veh:description&gt;Vehicle Type to be deleted&lt;/veh:description&gt;<br>    &lt;veh:logoImageB64&gt;&lt;/veh:logoImageB64&gt;<br>    &lt;veh:parentBrandNo&gt;0&lt;/veh:parentBrandNo&gt;<br>&lt;/veh:CreateVehicleType&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*y6vwAZEcp8Mf9kLyOC9z1w.png" /></figure><p>3. Proceed to define the sample <strong>DeleteVehicleType</strong> request as follows: <strong><em>(We will delete record no. 31)</em></strong></p><ul><li>vehicleTypeNo = 31</li></ul><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:veh=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>    &lt;veh:DeleteVehicleType&gt;<br>        &lt;veh:vehicleTypeNo&gt;31&lt;/veh:vehicleTypeNo&gt;<br>    &lt;/veh:DeleteVehicleType&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><p>4. Submit the request and confirm the response is as follows:</p><pre>&lt;Soap:Envelope xmlns:Soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>&lt;Soap:Body&gt;<br>    &lt;DeleteVehicleType_Result xmlns=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>        &lt;return_value&gt;Vehicle Type has been deleted successfully&lt;/return_value&gt;<br>    &lt;/DeleteVehicleType_Result&gt;<br>&lt;/Soap:Body&gt;<br>&lt;/Soap:Envelope&gt;</pre><p>5. Also check in Business Central if the record has been deleted.</p><h3>Service 6 — Deleting a specific Vehicle</h3><p>We will proceed to define the service on the file as follows:</p><ol><li>Add a new procedure <strong>DeleteVehicle</strong> with 1 parameter as follows:</li></ol><ul><li>VehicleNo: Integer;</li></ul><pre>procedure DeleteVehicle(<br>    VehicleNo: Integer<br>)<br>begin<br>    // ...<br>end;</pre><p>2. Modify the <strong>DeleteVehicle</strong> procedure to define the record update logic as follows:</p><pre>procedure DeleteVehicle(<br>    VehicleNo: Integer<br>): Text<br>var<br>    ExistingVehicle: Record &quot;Vehicle Register&quot;;<br>begin<br>    // First Check if the vehicle exists<br>    ExistingVehicle.Reset();<br><br>    ExistingVehicle.SetRange(&quot;No.&quot;, VehicleNo);<br><br>    if ExistingVehicle.FindFirst then begin<br>        ExistingVehicle.Delete(false);<br><br>        // Response message<br>        exit(&#39;Vehicle has been deleted successfully&#39;);<br>    end else begin<br>        // Vehicle has NOT been found<br>        Error(&#39;Vehicle referenced by no. %1 does NOT exist in the records&#39;, VehicleNo);<br>    end;<br>end;</pre><ul><li>Before deleting the vehicle record, we first search for it in the database table. If it does not exist, an error is thrown.</li><li>If the record exists, the record is deleted.</li></ul><p>3. Save the file and publish the changes</p><h3>Test using SOAP UI</h3><ol><li>Open <strong>SOAP UI</strong> and update the SOAP project <strong>Business Central Vehicle Management Service</strong> definition to add the new service <strong>DeleteVehicle</strong> we have created.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*cSU6OrTmilkNkR9mAvIkwg.png" /></figure><p>2. We will create a sample vehicle using the <strong>CreateVehicle</strong> that we will then delete using the <strong>DeleteVehicle</strong> service.</p><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:veh=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>&lt;veh:CreateVehicle&gt;<br>    &lt;veh:vehicleTypeNo&gt;2&lt;/veh:vehicleTypeNo&gt;<br>    &lt;veh:description&gt;Volkswagen Golf TEST DELETE&lt;/veh:description&gt;<br>    &lt;veh:registrationNo&gt;TEST DELETE&lt;/veh:registrationNo&gt;<br>&lt;/veh:CreateVehicle&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*W4DrwU7odMUQoHMqFYXfLw.png" /></figure><p>3. Proceed to define the sample <strong>DeleteVehicle</strong> request as follows: <strong><em>(We will delete record no. 19)</em></strong></p><ul><li>VehicleNo = 19</li></ul><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:veh=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>    &lt;veh:DeleteVehicle&gt;<br>        &lt;veh:vehicleNo&gt;19&lt;/veh:vehicleNo&gt;<br>    &lt;/veh:DeleteVehicle&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><p>4. Submit the request and confirm the response is as follows:</p><pre>&lt;Soap:Envelope xmlns:Soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>&lt;Soap:Body&gt;<br>    &lt;DeleteVehicle_Result xmlns=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>        &lt;return_value&gt;Vehicle has been deleted successfully&lt;/return_value&gt;<br>    &lt;/DeleteVehicle_Result&gt;<br>&lt;/Soap:Body&gt;<br>&lt;/Soap:Envelope&gt;</pre><p>5. Also check in Business Central if the record has been deleted.</p><p>Great. That’s it on SOAP APIs for our Business Central application. In the next few articles, we will explore the setup and testing of REST APIs in our app.</p><p>Next article…</p><p><a href="https://medium.com/@carmoseti/mb-820-series-web-services-vehicle-management-rest-2558b481c110">MB-820 Series: Web Services — Vehicle Management(REST)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd5104e35083" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MB-820 Series: Web Services — Vehicle Management(SOAP) — (Part 2)]]></title>
            <link>https://medium.com/@carmoseti/mb-820-series-web-services-vehicle-management-soap-part-2-c6c1aed6238a?source=rss-89ff1c016962------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6c1aed6238a</guid>
            <category><![CDATA[microsoft-dynamics-365]]></category>
            <category><![CDATA[microsoft-navision]]></category>
            <category><![CDATA[business-central]]></category>
            <category><![CDATA[dynamics-365]]></category>
            <category><![CDATA[mb-820]]></category>
            <dc:creator><![CDATA[Carlton Moseti]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 12:12:41 GMT</pubDate>
            <atom:updated>2025-06-02T12:26:44.188Z</atom:updated>
            <content:encoded><![CDATA[<h3>MB-820 Series: Web Services — Vehicle Management(SOAP) — (Part 2)</h3><h3>Get started on the MB-820 tutorial series</h3><p>The article below is part of a series of articles for the MB-820 tutorials. Click the link below to get started..</p><p><a href="https://medium.com/@carmoseti/mb-820-series-mastering-al-programming-for-microsoft-dynamics-business-central-e4025023dcde">MB-820 Series: Mastering AL Programming for Microsoft Dynamics Business Central</a></p><h3>Service 3 — Update a vehicle type</h3><p>We will proceed to define the service on the file as follows:</p><ol><li>Add a new procedure <strong>UpdateVehicleType</strong> with 5 parameters as follows:</li></ol><ul><li>VehicleTypeNo: Integer;</li><li>BrandName: Text;</li><li>Description: Text;</li><li>LogoImageB64: Text;</li><li>ParentBrandNo: Integer</li></ul><pre>procedure UpdateVehicleType(<br>    VehicleTypeNo: Integer;<br>    BrandName: Text;<br>    Description: Text;<br>    LogoImageB64: Text;<br>    ParentBrandNo: Integer<br>)<br>begin<br>    // ...<br>end;</pre><p>2. Modify the <strong>UpdateVehicleType</strong> procedure to define the record update logic as follows:</p><pre>procedure UpdateVehicleType(<br>    VehicleTypeNo: Integer;<br>    BrandName: Text;<br>    Description: Text;<br>    LogoImageB64: Text;<br>    ParentBrandNo: Integer<br>): Text<br>var<br>    ExistingVehicleType: Record &quot;Vehicle Types&quot;;<br>    TempBlob: Codeunit &quot;Temp Blob&quot;;<br>    OutStr: OutStream;<br>    Base64Convert: Codeunit &quot;Base64 Convert&quot;;<br>    StoreImageRef: FieldRef;<br>    StoreRecRef: RecordRef;<br>begin<br>    // First Check if the vehicle type exists<br>    ExistingVehicleType.Reset;<br><br>    // Filter using the VehicleNo field<br>    ExistingVehicleType.SetRange(&quot;No.&quot;, VehicleTypeNo);<br><br>    if ExistingVehicleType.FindFirst then begin<br>        // Vehicle has been found<br><br>        // Assign brand name value to the field &quot;Brand Name&quot;<br>        ExistingVehicleType.&quot;Brand Name&quot; := BrandName;<br>        // Assign description value to the field &quot;Description&quot;<br>        ExistingVehicleType.Description := Description;<br>        // Check if ParentBrandNo is defined<br>        if ParentBrandNo &lt;&gt; 0 then begin<br>            // Assign ParentBrandNo to the &quot;Parent No.&quot; field<br>            ExistingVehicleType.&quot;Parent No.&quot; := ParentBrandNo;<br>        end;<br><br>        /*<br>        Section to handle conversion of logo image from base64 text format to blob<br>        */<br>        // Check if LogoImageB64 is not empty string/text<br>        if LogoImageB64 &lt;&gt; &#39;&#39; then begin<br>            TempBlob.CreateOutStream(OutStr);<br>            Base64Convert.FromBase64(LogoImageB64, OutStr);<br>            Clear(ExistingVehicleType.&quot;Logo/Image&quot;);<br>            StoreRecRef.Open(50100);<br>            StoreImageRef := StoreRecRef.Field(ExistingVehicleType.FieldNo(&quot;Logo/Image&quot;));<br>            TempBlob.ToFieldRef(StoreImageRef);<br>            StoreImageRef.TestField();<br>            ExistingVehicleType.&quot;Logo/Image&quot; := StoreImageRef.Value;<br>            ExistingVehicleType.TestField(&quot;Logo/Image&quot;);<br>        end;<br><br>        // Update the Vehicle Type record while running the OnModify trigger<br>        ExistingVehicleType.Modify(true);<br><br>        // Response message<br>        exit(&#39;Vehicle Type has been updated successfully&#39;);<br>    end else begin<br>        // Vehicle has NOT been found<br>        Error(&#39;Vehicle Type referenced by no. %1 does NOT exist in the records&#39;, VehicleTypeNo);<br>    end;<br>end;</pre><ul><li>Before modifying the vehicle type record, we first search for it in the database table. If it does not exist, an error is thrown.</li><li>If the record exists, its fields are updated and the record is modified.</li></ul><p>3. Save the file and publish the changes</p><h3>Test using SOAP UI</h3><ol><li>Open <strong>SOAP UI</strong> and update the SOAP project <strong>Business Central Vehicle Management Service</strong> definition to add the new service <strong>UpdateVehicleType</strong> we have created.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*sLVceTRPqFO5WKVRKNvOxw.png" /></figure><p>2. Proceed to define the sample request as follows: <strong><em>(We will modify the description of record no. 29)</em></strong></p><ul><li>vehicleTypeNo = 29</li><li>brandName = Volkswagen Jetta</li><li>description = The Volkswagen Jetta is a compact car/small family car manufactured and marketed by Volkswagen since 1979.</li><li>logoImageB64 = <em>blank</em></li><li>parentBrandNo = 1 (Volkswagen)</li></ul><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:veh=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>    &lt;veh:UpdateVehicleType&gt;<br>        &lt;veh:vehicleTypeNo&gt;29&lt;/veh:vehicleTypeNo&gt;<br>        &lt;veh:brandName&gt;Volkswagen Jetta&lt;/veh:brandName&gt;<br>        &lt;veh:description&gt;The Volkswagen Jetta is a compact car/small family car manufactured and marketed by Volkswagen since 1979.&lt;/veh:description&gt;<br>        &lt;veh:logoImageB64&gt;&lt;/veh:logoImageB64&gt;<br>        &lt;veh:parentBrandNo&gt;1&lt;/veh:parentBrandNo&gt;<br>    &lt;/veh:UpdateVehicleType&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><p>3. Submit the request and confirm the response is as follows:</p><pre>&lt;Soap:Envelope xmlns:Soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>&lt;Soap:Body&gt;<br>    &lt;UpdateVehicleType_Result xmlns=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>        &lt;return_value&gt;Vehicle Type has been updated successfully&lt;/return_value&gt;<br>    &lt;/UpdateVehicleType_Result&gt;<br>&lt;/Soap:Body&gt;<br>&lt;/Soap:Envelope&gt;</pre><p>4. Also check in Business Central if the record has been modified.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*xlS5RD2IzsBq44E30axk8w.png" /></figure><p>5. We can try to modify a non-existent vehicle type. In the request modify <strong>vehicleTypeNo</strong> value to <strong>2900</strong> and submit the request. We see the response as follows:</p><pre>&lt;s:Envelope xmlns:s=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>&lt;s:Body&gt;<br>    &lt;s:Fault&gt;<br>        &lt;faultcode xmlns:a=&quot;urn:microsoft-dynamics-schemas/error&quot;&gt;a:Microsoft.Dynamics.Nav.Types.Exceptions.NavNCLDialogException&lt;/faultcode&gt;<br>        &lt;faultstring xml:lang=&quot;en-US&quot;&gt;Vehicle Type referenced by no. 2900 does NOT exist in the records&lt;/faultstring&gt;<br>        &lt;detail&gt;<br>            &lt;string xmlns=&quot;http://schemas.microsoft.com/2003/10/Serialization/&quot;&gt;Vehicle Type referenced by no. 2900 does NOT exist in the records&lt;/string&gt;<br>        &lt;/detail&gt;<br>    &lt;/s:Fault&gt;<br>&lt;/s:Body&gt;<br>&lt;/s:Envelope&gt;</pre><h3>Service 4 — Update a vehicle details</h3><p>We will proceed to define the service on the file as follows:</p><ol><li>Add a new procedure <strong>UpdateVehicle</strong> with 4 parameters as follows:</li></ol><ul><li>VehicleNo: Integer;</li><li>VehicleTypeNo: Integer;</li><li>Description: Text;</li><li>RegistrationNo: Text</li></ul><pre>procedure UpdateVehicle(<br>    VehicleNo: Integer;<br>    VehicleTypeNo: Integer;<br>    Description: Text;<br>    RegistrationNo: Text<br>)<br>begin<br>    // ...<br>end;</pre><p>2. Modify the <strong>UpdateVehicle</strong> procedure to define the record update logic as follows:</p><pre>procedure UpdateVehicle(<br>    VehicleNo: Integer;<br>    VehicleTypeNo: Integer;<br>    Description: Text;<br>    RegistrationNo: Text<br>): Text<br>var<br>    ExistingVehicle: Record &quot;Vehicle Register&quot;;<br>begin<br>    // First Check if the vehicle exists<br>    ExistingVehicle.Reset();<br><br>    ExistingVehicle.SetRange(&quot;No.&quot;, VehicleNo);<br><br>    if ExistingVehicle.FindFirst then begin<br>        ExistingVehicle.&quot;Vehicle Type No.&quot; := VehicleTypeNo;<br>        // Validate the TableRelation of the &quot;Vehicle Type No.&quot; field<br>        ExistingVehicle.Validate(&quot;Vehicle Type No.&quot;);<br><br>        ExistingVehicle.Description := Description;<br><br>        ExistingVehicle.&quot;Registration No.&quot; := RegistrationNo;<br>        // Run the validation logic on the OnValidate trigger of the field<br>        ExistingVehicle.Validate(&quot;Registration No.&quot;);<br><br>        ExistingVehicle.Modify(true);<br><br>        // Response message<br>        exit(&#39;Vehicle details has been modified successfully&#39;);<br>    end else begin<br>        // Vehicle has NOT been found<br>        Error(&#39;Vehicle referenced by no. %1 does NOT exist in the records&#39;, VehicleNo);<br>    end;<br>end;</pre><ul><li>Before modifying the vehicle record, we first search for it in the database table. If it does not exist, an error is thrown.</li><li>If the record exists, its fields are updated and the record is modified.</li></ul><p>3. Save the file and publish the changes</p><h3>Test using SOAP UI</h3><ol><li>Open <strong>SOAP UI</strong> and update the SOAP project <strong>Business Central Vehicle Management Service</strong> definition to add the new service <strong>UpdateVehicle</strong> we have created.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*A091FggLZo_jCJRKeJC8Ow.png" /></figure><p>2. Proceed to define the sample request as follows: <strong><em>(We will modify the description of record no. 17)</em></strong></p><ul><li>vehicleNo = 17</li><li>vehicleTypeNo = 27</li><li>description = 2023 Porsche, Yellow in color</li><li>registrationNo = REG027</li></ul><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:veh=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>    &lt;veh:UpdateVehicle&gt;<br>        &lt;veh:vehicleNo&gt;17&lt;/veh:vehicleNo&gt;<br>        &lt;veh:vehicleTypeNo&gt;27&lt;/veh:vehicleTypeNo&gt;<br>        &lt;veh:description&gt;2023 Porsche, Yellow in color&lt;/veh:description&gt;<br>        &lt;veh:registrationNo&gt;REG027&lt;/veh:registrationNo&gt;<br>    &lt;/veh:UpdateVehicle&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><p>3. Submit the request and confirm the response is as follows:</p><pre>&lt;Soap:Envelope xmlns:Soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>&lt;Soap:Body&gt;<br>    &lt;UpdateVehicle_Result xmlns=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>        &lt;return_value&gt;Vehicle details has been modified successfully&lt;/return_value&gt;<br>    &lt;/UpdateVehicle_Result&gt;<br>&lt;/Soap:Body&gt;<br>&lt;/Soap:Envelope&gt;</pre><p>4. Also check in Business Central if the record has been modified.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*L3uNNwtC2HJksvMRcuo9Zw.png" /></figure><p>5. We can try to modify a non-existent vehicle. In the request modify <strong>vehicleNo</strong> value to <strong>1700</strong> and submit the request. We see the response as follows:</p><pre>&lt;s:Envelope xmlns:s=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>&lt;s:Body&gt;<br>    &lt;s:Fault&gt;<br>        &lt;faultcode xmlns:a=&quot;urn:microsoft-dynamics-schemas/error&quot;&gt;a:Microsoft.Dynamics.Nav.Types.Exceptions.NavNCLDialogException&lt;/faultcode&gt;<br>        &lt;faultstring xml:lang=&quot;en-US&quot;&gt;Vehicle referenced by no. 1700 does NOT exist in the records&lt;/faultstring&gt;<br>        &lt;detail&gt;<br>            &lt;string xmlns=&quot;http://schemas.microsoft.com/2003/10/Serialization/&quot;&gt;Vehicle referenced by no. 1700 does NOT exist in the records&lt;/string&gt;<br>        &lt;/detail&gt;<br>    &lt;/s:Fault&gt;<br>&lt;/s:Body&gt;<br>&lt;/s:Envelope&gt;</pre><p>In the next article, we will proceed to define and test APIs for deleting our Vehicles and Vehicle Types.</p><p><a href="https://medium.com/@carmoseti/mb-820-series-web-services-vehicle-management-soap-part-3-cd5104e35083">MB-820 Series: Web Services — Vehicle Management(SOAP) — (Part 3)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6c1aed6238a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MB-820 Series: Web Services — Vehicle Management(SOAP) — (Part 1)]]></title>
            <link>https://medium.com/@carmoseti/mb-820-series-web-services-vehicle-management-soap-part-1-31a8a5d6763b?source=rss-89ff1c016962------2</link>
            <guid isPermaLink="false">https://medium.com/p/31a8a5d6763b</guid>
            <category><![CDATA[microsoft-dynamics-365]]></category>
            <category><![CDATA[dynamics-365]]></category>
            <category><![CDATA[microsoft-navision]]></category>
            <category><![CDATA[mb-820]]></category>
            <category><![CDATA[business-central]]></category>
            <dc:creator><![CDATA[Carlton Moseti]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 12:00:01 GMT</pubDate>
            <atom:updated>2025-06-02T12:13:15.447Z</atom:updated>
            <content:encoded><![CDATA[<h3>MB-820 Series: Web Services — Vehicle Management(SOAP) — (Part 1)</h3><h3>Get started on the MB-820 tutorial series</h3><p>The article below is part of a series of articles for the MB-820 tutorials. Click the link below to get started..</p><p><a href="https://medium.com/@carmoseti/mb-820-series-mastering-al-programming-for-microsoft-dynamics-business-central-e4025023dcde">MB-820 Series: Mastering AL Programming for Microsoft Dynamics Business Central</a></p><p>We will define a custom Codeunit <strong>Vehicle Management Service</strong> that will be used to provide Vehicle Management Services such as:</p><ol><li>Creating a new Vehicle Type</li><li>Creating/Registering a new Vehicle</li><li>Updating a Vehicle Type’s Details</li><li>Updating a Vehicle’s Details</li><li>Deleting a specific Vehicle Type</li><li>Deleting a specific Vehicle</li></ol><h3>Define Codeunit — Vehicle Management Service</h3><ol><li>Right click on the space below the <strong>.app</strong> file and click on the first menu option <strong><em>New AL File Wizard (AZ AL Dev Tools)</em></strong></li><li>You will be prompted to <strong>Select Wizard Type</strong>. Type the word <strong><em>Codeunit</em></strong> then hit ENTER</li><li>On the wizard, We will define a new Codeunit object: <strong>Vehicle Management Service</strong> as shown below. Once done click finish:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*WkyLrHzPSUkvKbyn7ALoIg.png" /><figcaption>Vehicle Management Service Codeunit</figcaption></figure><ul><li>We see that a new file <strong>Cod50102.VehicleManagemetService.al</strong> is created.</li></ul><h3>Service 1 — Create a new vehicle type</h3><p>We will proceed to define the service on the file as follows:</p><ol><li>Create a procedure <strong>CreateVehicleType</strong> with 4 parameters as follows:</li></ol><ul><li>BrandName: Text;</li><li>Description: Text;</li><li>LogoImageB64: Text;</li><li>ParentBrandNo: Integer</li></ul><pre>procedure CreateVehicleType(<br>    BrandName: Text;<br>    Description: Text;<br>    LogoImageB64: Text;<br>    ParentBrandNo: Integer<br>)<br>begin<br>    // ...<br>end;</pre><p>2. Modify the <strong>CreateVehicleType</strong> procedure to define the record creation logic as follows:</p><pre>procedure CreateVehicleType(<br>    BrandName: Text;<br>    Description: Text;<br>    LogoImageB64: Text;<br>    ParentBrandNo: Integer<br>): Text<br>var<br>    NewVehicleType: Record &quot;Vehicle Types&quot;;<br>begin<br>    // Initialize the record to be created/inserted<br>    NewVehicleType.Init();<br><br>    // Assign BrandName value to the field &quot;Brand Name&quot;<br>    NewVehicleType.&quot;Brand Name&quot; := BrandName;<br><br>    // Assign Description value to the field &quot;Description&quot;<br>    NewVehicleType.Description := Description;<br><br>    // Check if ParentBrandNo is defined<br>    if ParentBrandNo &lt;&gt; 0 then begin<br>        // Assign ParentBrandNo to the &quot;Parent No.&quot; field<br>        NewVehicleType.&quot;Parent No.&quot; := ParentBrandNo;<br>    end;<br><br>    /*<br>    Section to handle conversion of logo image from base64 text format to blob<br>    */<br>    // ...<br><br>    // Create the new Vehicle Type record while running the OnInsert trigger<br>    NewVehicleType.Insert(true);<br><br>    // Response message<br>    exit(&#39;Vehicle Type has been created successfully&#39;);<br>end;</pre><p>3. We also need to support the uploading of logo/images of the Vehicle Type. This may be achieved by using Base 64 encoding format which encodes/stores the image in the creation request in text format before converting to blob field for storage in Business Central. The code snippet below is used to handle the logo upload process.</p><pre>procedure CreateVehicleType(<br>    BrandName: Text;<br>    Description: Text;<br>    LogoImageB64: Text;<br>    ParentBrandNo: Integer<br>): Text<br>var<br>    NewVehicleType: Record &quot;Vehicle Types&quot;;<br>begin<br>    ...<br><br>    /*<br>    Section to handle conversion of logo image from base64 text format to blob<br>    */<br>    // Check if LogoImageB64 is not empty string/text<br>    if LogoImageB64 &lt;&gt; &#39;&#39; then begin<br>        /*<br>        TempBlob represents a temporary Blob (Binary Large Object) record.<br>        It&#39;s often used to store or manipulate large amounts of data,<br>        such as files or binary content,<br>        in memory without persisting them to the database.<br><br>        OutStr: A variable that will hold the output stream from the temporary blob<br>        */<br>        // 1. Initialize the OutStr variable. Creates an output stream from the temporary blob<br>        TempBlob.CreateOutStream(OutStr);<br><br>        /*<br>        LogoImageB64: A Text variable containing the Base64-encoded string.<br>        This represents the image/logo data encoded as Base64.<br><br>        OutStr: An OutStream variable where the decoded binary data will be written.<br>        */<br>        // 2. Decode the Base64-encoded string (LogoImageB64) and write the decoded binary data to the output stream.<br>        Base64Convert.FromBase64(LogoImageB64, OutStr);<br><br>        // 3. Reset/Empty the &quot;Logo/Image&quot; initial blob value<br>        Clear(NewVehicleType.&quot;Logo/Image&quot;);<br><br>        /*<br>        StoreRecRef: This is a variable of type RecordRef.<br><br>        A RecordRef allows you to work with any table in Business Central dynamically,<br>        without explicitly defining the table type at compile time.<br>        */<br><br>        // 4. The Open method is used to bind the RecordRef to table 50100 &quot;Vehicle Types&quot;<br>        StoreRecRef.Open(50100);<br><br>        /*<br>        StoreImageRef: A variable of type FieldRef.<br>        A FieldRef allows you to dynamically interact with a specific field in a RecordRef.<br><br>        NewVehicleType.FieldNo(&quot;Logo/Image&quot;): The FieldNo method retrieves the numeric field ID for the &quot;Logo/Image&quot; field from the NewVehicleType record variable.<br><br>        StoreRecRef.Field(FieldID): The Field method retrieves a FieldRef object for the specified field ID from the RecordRef.<br>        */<br>        // 5. The FieldRef representing the &quot;Logo/Image&quot; field from StoreRecRef is assigned to StoreImageRef<br>        StoreImageRef := StoreRecRef.Field(NewVehicleType.FieldNo(&quot;Logo/Image&quot;));<br><br>        // 6. Copy binary data of the image from the TempBlob record’s Blob field into the FieldRef (StoreImageRef).<br>        TempBlob.ToFieldRef(StoreImageRef);<br><br>        // 7. Check/Test if the FieldRef (StoreImageRef) has a Blob value. If empty an error will be thrown.<br>        StoreImageRef.TestField();<br><br>        // 8. Assign the Blob value from the FieldRef (StoreImageRef) to the &quot;Logo/Image&quot; Blob field<br>        NewVehicleType.&quot;Logo/Image&quot; := StoreImageRef.Value;<br><br>        // 9. Check/Test if the Field (&quot;Logo/Image&quot;) has a Blob value. If empty an error will be thrown.<br>        NewVehicleType.TestField(&quot;Logo/Image&quot;);<br>    end;<br><br>    ...<br>end;</pre><p>4. The final code of the <strong>Vehicle Management Service</strong> Codeunit is as follows:</p><pre>codeunit 50102 &quot;Vehicle Management Service&quot;<br>{<br>    procedure CreateVehicleType(<br>        BrandName: Text;<br>        Description: Text;<br>        LogoImageB64: Text;<br>        ParentBrandNo: Integer<br>    ): Text<br>    var<br>        NewVehicleType: Record &quot;Vehicle Types&quot;;<br>        TempBlob: Codeunit &quot;Temp Blob&quot;;<br>        OutStr: OutStream;<br>        Base64Convert: Codeunit &quot;Base64 Convert&quot;;<br>        StoreImageRef: FieldRef;<br>        StoreRecRef: RecordRef;<br>    begin<br>        // Initialize the record<br>        NewVehicleType.Init();<br><br>        // Assign brand name value to the field &quot;Brand Name&quot;<br>        NewVehicleType.&quot;Brand Name&quot; := BrandName;<br>        // Assign description value to the field &quot;Description&quot;<br>        NewVehicleType.Description := Description;<br>        // Check if ParentBrandNo is defined<br>        if ParentBrandNo &lt;&gt; 0 then begin<br>            // Assign ParentBrandNo to the &quot;Parent No.&quot; field<br>            NewVehicleType.&quot;Parent No.&quot; := ParentBrandNo;<br>        end;<br><br>        /*<br>        Section to handle conversion of logo image from base64 text format to blob<br>        */<br>        // Check if LogoImageB64 is not empty string/text<br>        if LogoImageB64 &lt;&gt; &#39;&#39; then begin<br>            /*<br>            TempBlob represents a temporary Blob (Binary Large Object) record.<br>            It&#39;s often used to store or manipulate large amounts of data,<br>            such as files or binary content,<br>            in memory without persisting them to the database.<br><br>            OutStr: A variable that will hold the output stream from the temporary blob<br>            */<br>            // 1. Initialize the OutStr variable. Creates an output stream from the temporary blob<br>            TempBlob.CreateOutStream(OutStr);<br><br>            /*<br>            LogoImageB64: A Text variable containing the Base64-encoded string.<br>            This represents the image/logo data encoded as Base64.<br><br>            OutStr: An OutStream variable where the decoded binary data will be written.<br>            */<br>            // 2. Decode the Base64-encoded string (LogoImageB64) and write the decoded binary data to the output stream.<br>            Base64Convert.FromBase64(LogoImageB64, OutStr);<br><br>            // 3. Reset/Empty the &quot;Logo/Image&quot; initial blob value<br>            Clear(NewVehicleType.&quot;Logo/Image&quot;);<br><br>            /*<br>            StoreRecRef: This is a variable of type RecordRef.<br><br>            A RecordRef allows you to work with any table in Business Central dynamically,<br>            without explicitly defining the table type at compile time.<br>            */<br><br>            // 4. The Open method is used to bind the RecordRef to table 50100 &quot;Vehicle Types&quot;<br>            StoreRecRef.Open(50100);<br><br>            /*<br>            StoreImageRef: A variable of type FieldRef.<br>            A FieldRef allows you to dynamically interact with a specific field in a RecordRef.<br><br>            NewVehicleType.FieldNo(&quot;Logo/Image&quot;): The FieldNo method retrieves the numeric field ID for the &quot;Logo/Image&quot; field from the NewVehicleType record variable.<br><br>            StoreRecRef.Field(FieldID): The Field method retrieves a FieldRef object for the specified field ID from the RecordRef.<br>            */<br>            // 5. The FieldRef representing the &quot;Logo/Image&quot; field from StoreRecRef is assigned to StoreImageRef<br>            StoreImageRef := StoreRecRef.Field(NewVehicleType.FieldNo(&quot;Logo/Image&quot;));<br><br>            // 6. Copy binary data of the image from the TempBlob record’s Blob field into the FieldRef (StoreImageRef).<br>            TempBlob.ToFieldRef(StoreImageRef);<br><br>            // 7. Check/Test if the FieldRef (StoreImageRef) has a Blob value. If empty an error will be thrown.<br>            StoreImageRef.TestField();<br><br>            // 8. Assign the Blob value from the FieldRef (StoreImageRef) to the &quot;Logo/Image&quot; Blob field<br>            NewVehicleType.&quot;Logo/Image&quot; := StoreImageRef.Value;<br><br>            // 9. Check/Test if the Field (&quot;Logo/Image&quot;) has a Blob value. If empty an error will be thrown.<br>            NewVehicleType.TestField(&quot;Logo/Image&quot;);<br>        end;<br><br>        // Create the new Vehicle Type record while running the OnInsert trigger<br>        NewVehicleType.Insert(true);<br><br>        // Response message<br>        exit(&#39;Vehicle Type has been created successfully&#39;);<br>    end;<br>}</pre><p>5. Save the file and publish the changes</p><h3>Define Web Service — Vehicle Management Service</h3><ol><li>We will define our Web Service on the web services list page as follows:</li></ol><ul><li>Object Type = <strong><em>Codeunit</em></strong></li><li>Object Id = <strong><em>50102</em></strong></li><li>Service Name = <strong><em>VehicleManagementService</em></strong></li><li>Published = <strong><em>true</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JTvSbWejGD5_tQhvYWAwLQ.png" /></figure><p>2. Click on the <strong>SOAP URL</strong> field of the web service, login and confirm it’s WSDL XML response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ez4JFEnm4oE0j520z2g5SQ.png" /></figure><h3>Test using SOAP UI — Without Logo</h3><ol><li>Open <strong>SOAP UI</strong> and setup a new SOAP project <strong>Business Central Vehicle Management Service</strong>. Use the <strong>SOAP URL</strong> provided to complete setup of the project.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*-F85i8XkRCJkxrbRJufyFA.png" /></figure><p>2. We will push 2 sample requests, the first one without the logo image. Proceed to define the first sample request as follows:</p><ul><li>brandName = Volkswagen Jetta</li><li>description = Volkswagen Jetta</li><li>logoImageB64 = <em>blank</em></li><li>parentBrandNo = 1 (Volkswagen)</li></ul><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:veh=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>    &lt;veh:CreateVehicleType&gt;<br>        &lt;veh:brandName&gt;Volkswagen Jetta&lt;/veh:brandName&gt;<br>        &lt;veh:description&gt;Volkswagen Jetta&lt;/veh:description&gt;<br>        &lt;veh:logoImageB64&gt;&lt;/veh:logoImageB64&gt;<br>        &lt;veh:parentBrandNo&gt;1&lt;/veh:parentBrandNo&gt;<br>    &lt;/veh:CreateVehicleType&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><p>3. Submit the request and confirm the response is as follows:</p><pre>&lt;Soap:Envelope xmlns:Soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>&lt;Soap:Body&gt;<br>    &lt;CreateVehicleType_Result xmlns=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>        &lt;return_value&gt;Vehicle Type has been created successfully&lt;/return_value&gt;<br>    &lt;/CreateVehicleType_Result&gt;<br>&lt;/Soap:Body&gt;<br>&lt;/Soap:Envelope&gt;</pre><p>4. Also check in Business Central if the new record has been inserted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*2DUkwgGw5tiyp1FKQ77TFg.png" /></figure><h3>Test using SOAP UI — With Logo/Image</h3><ol><li>For the 2nd request, we will be creating a new Volkswagen brand: <strong>Tiguan</strong>.</li></ol><ul><li>Proceed to download online a <strong>.jpg/.png</strong> image of a Volkswagen Tiguan</li><li>Navigate to the website: <strong><em>Base64 Guru — Image to Base 64</em></strong> where we will upload our image file to be encoded to Base64 text format.</li></ul><p><a href="https://base64.guru/converter/encode/image">Image to Base64</a></p><ul><li>Upload your image file and encode the image to base 64.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u45fxomJ-IxzjCmKyrRP5g.png" /></figure><ul><li>Save / Copy the base 64 contents for use in the next request.</li></ul><p>2. We will push the 2nd request with the logo image. Proceed to define the sample request as follows:</p><ul><li>brandName = Volkswagen Tiguan</li><li>description = Volkswagen Tiguan</li><li>logoImageB64 = <strong><em>BASE_64_CONTENTS</em></strong></li><li>parentBrandNo = 1 (Volkswagen)</li></ul><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:veh=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>    &lt;veh:CreateVehicleType&gt;<br>        &lt;veh:brandName&gt;Volkswagen Tiguan&lt;/veh:brandName&gt;<br>        &lt;veh:description&gt;Volkswagen Tiguan&lt;/veh:description&gt;<br>        &lt;veh:logoImageB64&gt;BASE_64_CONTENTS&lt;/veh:logoImageB64&gt;<br>        &lt;veh:parentBrandNo&gt;1&lt;/veh:parentBrandNo&gt;<br>    &lt;/veh:CreateVehicleType&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><p>3. Submit the request and confirm the response is as follows:</p><pre>&lt;Soap:Envelope xmlns:Soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>&lt;Soap:Body&gt;<br>    &lt;CreateVehicleType_Result xmlns=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>        &lt;return_value&gt;Vehicle Type has been created successfully&lt;/return_value&gt;<br>    &lt;/CreateVehicleType_Result&gt;<br>&lt;/Soap:Body&gt;<br>&lt;/Soap:Envelope&gt;</pre><p>4. Also check in Business Central if the new record has been inserted. Confirm that the vehicle image is visible for the vehicle type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tbiVz3-ej_2sl3ltW6mvpQ.png" /></figure><h3>Service 2 — Create a new vehicle</h3><p>We will proceed to define the service on the file as follows:</p><ol><li>Add a new procedure <strong>CreateVehicle</strong> with 4 parameters as follows:</li></ol><ul><li>VehicleTypeNo: Integer;</li><li>Description: Text;</li><li>RegistrationNo: Text;</li></ul><pre>procedure CreateVehicle(<br>    VehicleTypeNo: Integer;<br>    Description: Text;<br>    RegistrationNo: Text<br>)<br>begin<br>    // ...<br>end;</pre><p>2. Modify the <strong>CreateVehicle</strong> procedure to define the record creation logic as follows:</p><pre>procedure CreateVehicle(<br>    VehicleTypeNo: Integer;<br>    Description: Text;<br>    RegistrationNo: Text<br>): Text<br>var<br>    NewVehicle: Record &quot;Vehicle Register&quot;;<br>begin<br>    NewVehicle.Init();<br><br>    NewVehicle.&quot;Vehicle Type No.&quot; := VehicleTypeNo;<br>    // Validate the TableRelation of the &quot;Vehicle Type No.&quot; field<br>    NewVehicle.Validate(&quot;Vehicle Type No.&quot;);<br><br>    NewVehicle.Description := Description;<br><br>    NewVehicle.&quot;Registration No.&quot; := RegistrationNo;<br>    // Run the validation logic on the OnValidate trigger of the field<br>    NewVehicle.Validate(&quot;Registration No.&quot;);<br><br>    NewVehicle.Insert(true);<br><br>    // Response message<br>    exit(&#39;New Vehicle has been created successfully&#39;);<br>end;</pre><p>3. Save the file and publish the changes</p><h3>Test using SOAP UI</h3><ol><li>Open <strong>SOAP UI</strong> and update the SOAP project <strong>Business Central Vehicle Management Service</strong> definition to add the new service <strong>CreateVehicle</strong> we have created.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*sBgrl5ybCSs8DaIz49gtFQ.png" /></figure><p>2. Proceed to define the sample request as follows:</p><ul><li>vehicleTypeNo = 2 (Volkswagen Golf)</li><li>description = Volkswagen Golf REG 999</li><li>registrationNo = REG 999</li></ul><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:veh=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>    &lt;veh:CreateVehicle&gt;<br>        &lt;veh:vehicleTypeNo&gt;2&lt;/veh:vehicleTypeNo&gt;<br>        &lt;veh:description&gt;Volkswagen Golf REG 999&lt;/veh:description&gt;<br>        &lt;veh:registrationNo&gt;REG 999&lt;/veh:registrationNo&gt;<br>    &lt;/veh:CreateVehicle&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><p>3. Submit the request and confirm the response is as follows:</p><pre>&lt;Soap:Envelope xmlns:Soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>&lt;Soap:Body&gt;<br>    &lt;CreateVehicle_Result xmlns=&quot;urn:microsoft-dynamics-schemas/codeunit/VehicleManagementService&quot;&gt;<br>        &lt;return_value&gt;New Vehicle has been created successfully&lt;/return_value&gt;<br>    &lt;/CreateVehicle_Result&gt;<br>&lt;/Soap:Body&gt;<br>&lt;/Soap:Envelope&gt;</pre><p>4. Also check in Business Central if the new record has been inserted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*FLQ2YWeBtjMAgl3yVYgusw.png" /></figure><p>In the next article, we will proceed to define and test APIs for updating our Vehicles and Vehicle Types.</p><p><a href="https://medium.com/@carmoseti/mb-820-series-web-services-vehicle-management-soap-part-2-c6c1aed6238a">MB-820 Series: Web Services — Vehicle Management(SOAP) — (Part 2)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31a8a5d6763b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MB-820 Series: Web Services (Part 3)]]></title>
            <link>https://medium.com/@carmoseti/mb-820-series-web-services-part-3-94769f331518?source=rss-89ff1c016962------2</link>
            <guid isPermaLink="false">https://medium.com/p/94769f331518</guid>
            <category><![CDATA[mb-820]]></category>
            <category><![CDATA[business-central]]></category>
            <category><![CDATA[microsoft-dynamics-365]]></category>
            <category><![CDATA[microsoft-365]]></category>
            <category><![CDATA[microsoft-navision]]></category>
            <dc:creator><![CDATA[Carlton Moseti]]></dc:creator>
            <pubDate>Sat, 31 May 2025 16:38:46 GMT</pubDate>
            <atom:updated>2025-06-02T12:00:30.484Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get started on the MB-820 tutorial series</h3><p>The article below is part of a series of articles for the MB-820 tutorials. Click the link below to get started..</p><p><a href="https://medium.com/@carmoseti/mb-820-series-mastering-al-programming-for-microsoft-dynamics-business-central-e4025023dcde">MB-820 Series: Mastering AL Programming for Microsoft Dynamics Business Central</a></p><h3>Web Services — Install and Test using Postman</h3><p>Postman is a widely used API testing tool for SOAP and REST API endpoints. Apart from testing APIs, Postman also allows for collaborative development whereby multiple developers can test and document their APIs as they share ampng themselves. We will proceed to setup and test our <strong>Calculator Service</strong> using Postman.</p><p><a href="https://www.postman.com/">Postman: The World&#39;s Leading API Platform | Sign Up for Free</a></p><h3>Download and Install Postman</h3><ol><li>Navigate to the <strong>Postman</strong> website and download the desktop app for Windows.</li><li>Install the software.</li></ol><ul><li>You will be prompted to create a Postman account. Proceed to create a Postman account.</li><li>Once done, complete installation of Postman</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*No1WMkUcYN5ztOlF9gHWkA.png" /></figure><h3>Define Postman Collection — Business Central Calculator Service</h3><ol><li>Once installed successfully, Click on the <strong><em>Create Collection</em></strong> button to create our <strong>Business Central Calculator Service</strong> collection. A postman collection is a folder of different API services/endpoints that are related.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*aZ2Ylxo7ju8-LO6ASp1HXw.png" /></figure><p>2. Click on the <strong>Variables</strong> tab to define the various variables that will be accessed by our SOAP service requests. Define the various <strong>“Current Value”</strong> column variables as follows <strong><em>(Leave the “Initial value” column as blank)</em></strong>:</p><ul><li><strong>soap_url</strong> = <strong><em>&lt;YOUR SOAP URL&gt;</em></strong> e.g. <a href="http://win-dgqlvoicjqf:7047/BC250/WS/CRONUS%20International%20Ltd./Codeunit/CalculatorService">http://win-dgqlvoicjqf:7047/BC250/WS/CRONUS%20International%20Ltd./Codeunit/CalculatorService</a></li><li><strong>ntlm_username</strong> = <strong><em>&lt;YOUR BC USERNAME&gt;</em></strong> e.g. Administrator</li><li><strong>ntlm_password</strong> = <strong><em>&lt;YOUR BC PASSWORD&gt;</em></strong></li><li><strong>soap_action_header</strong> = <strong><em>urn:microsoft-dynamics-schemas/codeunit/CalculatorService</em></strong>. <strong>SoapAction</strong> is a header type used when making SOAP service requests.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dr38HOwvUmch9u_KhJvUfw.png" /></figure><p>3. Click on the <strong>Authorization</strong> tab to define the NTLM authentication credentials for reaching the SOAP service.</p><ul><li>Select <strong>Auth Type</strong> = <strong><em>NTLM Authentication</em></strong></li><li>Username = <strong>{{ntlm_username}}</strong></li><li>Password = <strong>{{ntlm_password}}</strong></li><li>In Postman we reference variables using the double curly brackets ({{variable}})</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*NLSwtlooQ7c1UtG-MobbgQ.png" /></figure><h3>Configure and Test Service — Addition</h3><ol><li>Open the SoapUI project and double click on the <strong>Request 1</strong> button of the <strong>Addition</strong> service. Click on the <strong>RAW</strong> tab of the request section so as to view the RAW request headers that were generated by SoapUI when submitting the request.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*e6f3zyNOhKqW8yTv02iGDg.png" /></figure><p>Take note of the following 3 headers:</p><ul><li>HTTP method = <strong>POST</strong></li><li>Content-Type = <strong>text/xml</strong></li><li>SoapAction = <strong>urn:microsoft-dynamics-schemas/codeunit/CalculatorService:Addition</strong></li></ul><p>We will configure our Postman collection requests to use these values.</p><p>2. On the left sidebar navigation below your collection, click on the link <strong>Add a request</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*Dr7LSgr4QDE916p1mKU0ZQ.png" /></figure><ul><li>Name the request as <strong><em>Addition</em></strong></li><li>Change the HTTP method dropdown value from <strong>GET</strong> to <strong>POST</strong>. SOAP requests use HTTP method <strong>POST</strong></li><li>On the <strong><em>Enter URL or paste text</em></strong> input, key in the variable <strong>{{soap_url}}</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*S9rK32tF_s1PhWiZBy9gkA.png" /></figure><p>3. Click on the <strong>Headers</strong> tab and configure as follows:</p><ul><li>Add key <strong>SoapAction</strong> with value = <strong>{{soap_action_header}}:Addition</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*eWo5EbSE9EBIpl9v3niJWw.png" /></figure><p>4. Click on the <strong>Body</strong> tab and configure as follows:</p><ul><li>Choose the body option as <strong>raw</strong>.</li><li>Click on the last dropdown <strong>JSON</strong> and pick the value <strong>XML</strong>.</li><li>Go back to SoapUI and copy the XML contents of the request body of the <strong>Addition</strong> service.</li></ul><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:cal=&quot;urn:microsoft-dynamics-schemas/codeunit/CalculatorService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>    &lt;cal:Addition&gt;<br>        &lt;cal:number1&gt;5&lt;/cal:number1&gt;<br>        &lt;cal:number2&gt;16&lt;/cal:number2&gt;<br>    &lt;/cal:Addition&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><ul><li>Paste the contents on the body section in Postman</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eb37ytAsooQp8IWxAkvgsw.png" /></figure><p>5. Once done, save your changes CTRL + S then click the <strong>Send</strong> button to submit the request. We observe that the request is successful with status <strong>200 OK</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*AEvK7wtlDQGUZeDDYIMpSw.png" /></figure><pre>&lt;Soap:Envelope xmlns:Soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>    &lt;Soap:Body&gt;<br>        &lt;Addition_Result xmlns=&quot;urn:microsoft-dynamics-schemas/codeunit/CalculatorService&quot;&gt;<br>            &lt;return_value&gt;21&lt;/return_value&gt;<br>        &lt;/Addition_Result&gt;<br>    &lt;/Soap:Body&gt;<br>&lt;/Soap:Envelope&gt;</pre><p>6. We will proceed to save the response as a documented example that will be part of our collection.</p><ul><li>On the top left of the response body section is the <strong>Save Response</strong> button. Click on it and save the successful request with the name <strong>Addition — SUCCESS</strong>. This will form part of the SOAP API tests documentation when sharing the collection to other developers. They will be able to see sample requests and responses data of the service.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FqRgIbPQW7rJobIAgvsxNg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*Lr_dIXHKXeA5VlLh7dXZDA.png" /></figure><h3>Configure and Test Service — Division</h3><ol><li>Open the SoapUI project and double click on the <strong>Request 1</strong> button of the <strong>Division</strong> service. Click on the <strong>RAW</strong> tab of the request section so as to view the RAW request headers that were generated by SoapUI when submitting the request.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*5QALbg6GJMOxObvOqlZ7JQ.png" /></figure><p>Take note of the following 3 headers:</p><ul><li>HTTP method = <strong>POST</strong></li><li>Content-Type = <strong>text/xml</strong></li><li>SoapAction = <strong>urn:microsoft-dynamics-schemas/codeunit/CalculatorService:Division</strong></li></ul><p>We will configure our Postman collection requests to use these values.</p><p>2. On the left sidebar navigate to the previous service <strong>Addition</strong>, then right click and choose the <strong>Duplicate</strong> menu. Alternatively type CTRL + D after selecting the <strong>Addition</strong> request. We see that a new service request <strong>Addition Copy</strong> is generated below the <strong>Addition</strong> request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*5rpxrbYTyFHucJUbW4DEcQ.png" /></figure><ul><li>Rename <strong>Addition Copy</strong> to <strong>Division</strong></li></ul><p>3. Click on the <strong>Headers</strong> tab and configure as follows:</p><ul><li>Update key <strong>SoapAction</strong> with value = <strong>{{soap_action_header}}:Division</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*4sBN0WbCMeaxhY3gzgON1Q.png" /></figure><p>4. Click on the <strong>Body</strong> tab and configure as follows:</p><ul><li>Go back to SoapUI and copy the XML contents of the request body of the <strong>Division</strong> service.</li></ul><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:cal=&quot;urn:microsoft-dynamics-schemas/codeunit/CalculatorService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>    &lt;cal:Division&gt;<br>        &lt;cal:number1&gt;16&lt;/cal:number1&gt;<br>        &lt;cal:divisor&gt;4&lt;/cal:divisor&gt;<br>    &lt;/cal:Division&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><ul><li>Paste the contents on the body section in Postman</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*BLS-db4zF_0f5GwTlR4s9A.png" /></figure><p>5. Once done, save your changes CTRL + S then click the <strong>Send</strong> button to submit the request. We observe that the request is successful with status <strong>200 OK</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*PlcAmojAR-KIGjN1dniZGA.png" /></figure><pre>&lt;Soap:Envelope xmlns:Soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>    &lt;Soap:Body&gt;<br>        &lt;Division_Result xmlns=&quot;urn:microsoft-dynamics-schemas/codeunit/CalculatorService&quot;&gt;<br>            &lt;return_value&gt;4&lt;/return_value&gt;<br>        &lt;/Division_Result&gt;<br>    &lt;/Soap:Body&gt;<br>&lt;/Soap:Envelope&gt;</pre><p>6. We will proceed to save the response as a documented example that will be part of our collection.</p><ul><li>On the top left of the response body section is the <strong>Save Response</strong> button. Click on it and save the successful request with the name <strong>Division — SUCCESS</strong>.</li><li>You can delete the <strong>Addition — SUCCESS</strong> example that is under the <strong>Division</strong> request.</li></ul><h3>Configure and Test Service — Multiplication, Subtraction, Modulus</h3><p>Similarly, using the steps from the previous section, you can proceed to add the other 3 services to the Postman collection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*kdW2Og286oPTGQOz27RVdQ.png" /></figure><p>Good. That’s it on a solid base for testing our Business Central SOAP APIs using Postman. We have been testing using a sample service: <strong>Calculator Service</strong>. In the next couple of articles, we will build and test a web services for our Vehicle Inventory application.</p><p>Next article…</p><p><a href="https://medium.com/@carmoseti/mb-820-series-web-services-vehicle-management-soap-part-1-31a8a5d6763b">MB-820 Series: Web Services — Vehicle Management(SOAP) — (Part 1)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94769f331518" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MB-820 Series: Web Services (Part 2)]]></title>
            <link>https://medium.com/@carmoseti/mb-820-series-web-services-part-2-b13b7a93f219?source=rss-89ff1c016962------2</link>
            <guid isPermaLink="false">https://medium.com/p/b13b7a93f219</guid>
            <category><![CDATA[microsoft-navision]]></category>
            <category><![CDATA[mb-820]]></category>
            <category><![CDATA[dynamics-365]]></category>
            <category><![CDATA[microsoft-dynamics-365]]></category>
            <category><![CDATA[business-central]]></category>
            <dc:creator><![CDATA[Carlton Moseti]]></dc:creator>
            <pubDate>Sat, 31 May 2025 16:13:11 GMT</pubDate>
            <atom:updated>2025-05-31T16:39:19.648Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get started on the MB-820 tutorial series</h3><p>The article below is part of a series of articles for the MB-820 tutorials. Click the link below to get started..</p><p><a href="https://medium.com/@carmoseti/mb-820-series-mastering-al-programming-for-microsoft-dynamics-business-central-e4025023dcde">MB-820 Series: Mastering AL Programming for Microsoft Dynamics Business Central</a></p><h3>Web Services — Install SOAP UI</h3><p>SoapUI is a widely used testing tool for SOAP and REST API endpoints. We will use SOAP UI to discover the services offered on a given SOAP URL, the input parameters for each service and the structure of the response after testing the services:</p><p><a href="https://www.soapui.org/">Download REST &amp; SOAP Automated API Testing Tool | Open Source | SoapUI</a></p><h3>Enable NTLM Authentication</h3><p>Before testing our SOAP URL services, we need to enable NTLM authentication for SOAP services in Business Central. NTLM authentication is disabled by default during installation. We will use the <strong>Business Central Administration Shell</strong> to enable this setting.</p><ol><li>On the Windows search menu, type <strong>Business Central Administration Shell</strong>. Right click on the menu and click <strong>Run as Administrator</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*4WhojfdeS6nCT-cwQUSl_w.png" /></figure><p>2. On the CMD window, type the command <strong>Get-NAVServerConfiguration</strong> then hit ENTER. You will be prompted for the <strong>ServerInstance</strong> value. Input the value of your BC instance name. E.g <strong>BC250</strong> then hit ENTER. A list of configurations will be printed on the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*8hXZ6X_8kPziugncJyTdeA.png" /></figure><p>3. On the screen scroll towards the bottom (the configurations are sorted alphabetically) and locate the <strong>ServicesUseNTLMAuthentication</strong> configuration. Note that it is set to <strong>false</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*-11Gv0xdZziCBzhn9taSag.png" /></figure><p>4. We will change the value to <strong>true</strong> by using the <strong>Set-NAVServerConfiguration</strong> command as below:</p><pre>Set-NAVServerConfiguration -KeyName ServicesUseNTLMAuthentication -KeyValue &quot;true&quot;</pre><ul><li>Execute the command on the BC Administration Shell. Input the value of your BC instance name. E.g <strong>BC250</strong> then hit ENTER</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*Q-dwi5kSg71Fean4qhTIQg.png" /></figure><ul><li>You will be notified that the Business Central service will need to be restarted for the configuration change to take effect. Use the command below to restart the service:</li></ul><pre>Restart-NAVServerInstance -Verbose</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*L6n4q-yQVntd35R_zFXPnA.png" /></figure><p>5. More information on the Business Central Management commands may be found on the link below:</p><ul><li><a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.dynamics.nav.management/?view=businesscentral-ps-24">Microsoft.BusinessCentral.Management Module - Dynamics NAV</a></li><li><a href="https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/configure-server-instance">Configure Business Central Server - Business Central</a></li></ul><h3>Download and Install SoapUI</h3><ol><li>Navigate to the <strong>SoapUI</strong> website and download the <strong>SoapUI Open Source</strong> software.</li><li>Install the software using the default options suggested on the installation wizard.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*FvyBxFZnOhNnD7_ibsqjPg.png" /></figure><p>3. Once installed successfully, Click on the <strong><em>New SOAP Project</em></strong> link to create our <strong>Business Central Calculator Service</strong> project. Define as follows:</p><ul><li>Project Name = <strong>Business Central Calculator Service</strong></li><li>Initial WSDL = <strong>&lt;YOUR CALCULATOR SERVICE SOAP URL&gt;</strong> e.g <a href="http://win-dgqlvoicjqf:7047/BC250/WS/CRONUS%20International%20Ltd./Codeunit/CalculatorService"><strong><em>http://win-dgqlvoicjqf:7047/BC250/WS/CRONUS%20International%20Ltd./Codeunit/CalculatorService</em></strong></a></li><li>Create Requests = Enabled/Checked.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*FdS5IL8gmA9vjdwVkdhOrw.png" /></figure><p>4. Click <strong>OK</strong>. You will be prompted for <strong>NT Authentication</strong>. Input your Business Central account’s credentials then click <strong>OK</strong> to proceed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*wVOXTqvj5ovM1gmsI6lvdw.png" /></figure><p>5. On the left sidebar, we see that the project is setup as defined above and the 4 services we had defined on our <strong>Calculator Service</strong> have been listed on the project setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*GnwTvAhwbE47aNzsm_y4XA.png" /></figure><h3>Web Services — Testing using SOAP UI</h3><p>After setting up our SOAP project in SOAP UI we now proceed to test the 4 services from our <strong>Calculator Service</strong></p><h3>Testing — Calculator Service (Addition)</h3><ol><li>Click on the <strong>+</strong> icon on the <strong>Addition</strong> service then double click on <strong>Request 1</strong> menu. A request window is opened:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*cf31YP5yR76tgoM8teI5RQ.png" /></figure><p>2. The request window is split into the request body section on the left and a blank response body section on the right. SOAP UI reads the WSDL from the SOAP URL and defines the structure of the request body for each service. So we just need to replace the body parameters ”?” with actual values, define authentication and thereafter call the SOAP service.</p><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:cal=&quot;urn:microsoft-dynamics-schemas/codeunit/CalculatorService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>    &lt;cal:Addition&gt;<br>        &lt;cal:number1&gt;?&lt;/cal:number1&gt;<br>        &lt;cal:number2&gt;?&lt;/cal:number2&gt;<br>    &lt;/cal:Addition&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><p>Replace the ”?” with sample values. E.g number1 = 5, number2 = 16</p><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:cal=&quot;urn:microsoft-dynamics-schemas/codeunit/CalculatorService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>    &lt;cal:Addition&gt;<br>        &lt;cal:number1&gt;5&lt;/cal:number1&gt;<br>        &lt;cal:number2&gt;16&lt;/cal:number2&gt;<br>    &lt;/cal:Addition&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><p>Define authentication of the request.</p><ul><li>On the bottom of the request window, click on the first button, the <strong>Auth</strong> menu.</li><li>Click on the <strong>No Authorization</strong> dropdown menu and Select <strong>Add New Authorization…</strong>.</li><li>A popup menu is displayed. Set authorization <strong>Type</strong> to <strong><em>NTLM</em></strong> then press <strong>OK</strong>.</li><li>A form is displayed. Set your credentials as per your Business Central account. <strong>Domain</strong> value is not mandatory.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*tzWvldxbMDnFSsiBfhYYOw.png" /></figure><p>3. Once done proceed to submit the request by clicking the <strong>Green Arrow Icon</strong> button or by pressing the keys ALT + ENTER</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*SM1ps4dOhUKyxdTomnXyZQ.png" /></figure><p>On the left of the response window, click on the <strong>XML</strong> tab to view the response in XML format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*mGXgoTpyHvTrdumA1Ivbqg.png" /></figure><p>From the XML response body, we see that the result of the <strong>sum of 16 and 5</strong> is <strong>21</strong> and it is stored in the <strong>return_value</strong> tag of the XML response.</p><pre>&lt;Soap:Envelope xmlns:Soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>&lt;Soap:Body&gt;<br>    &lt;Addition_Result xmlns=&quot;urn:microsoft-dynamics-schemas/codeunit/CalculatorService&quot;&gt;<br>        &lt;return_value&gt;21&lt;/return_value&gt;<br>    &lt;/Addition_Result&gt;<br>&lt;/Soap:Body&gt;<br>&lt;/Soap:Envelope&gt;</pre><p>Similarly, you may proceed to test the other 3 services.</p><h3>Testing — Calculator Service (Division)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*nDRWFkKEJk2XS8NEIvGv-w.png" /></figure><h3>Testing — Calculator Service (Multiplication)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*bhwNlsbfRfMspAfhH4LsPA.png" /></figure><h3>Testing — Calculator Service (Subtraction)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9xXjwPAa4jtJKtWKUQPiug.png" /></figure><h3>Web Services — Handling Codeunit Updates</h3><p>We will make some changes on our <strong>Calculator Service</strong> Codeunit file and how to retrieve them from our SoapUI project.</p><h3>Modify — Calculator Service</h3><ol><li>Open the file <strong>Cod50101.CalculatorService.al</strong> and modify as follows:</li></ol><ul><li>On the <strong>Division</strong> procedure, rename the variable <strong><em>Number2</em></strong> to <strong>Divisor</strong></li></ul><pre>...<br><br>procedure Division(Number1: Integer; Divisor: Integer): Integer<br>begin<br>    // Divide Number1 by Divisor<br>    exit(Number1 / Divisor);<br>end;<br><br>...</pre><ul><li>Add a new service/procedure <strong>Modulus</strong> that will be used to calculate and return the value of the remainder after dividing <strong>Number1</strong> with <strong>Divisor</strong>.</li></ul><pre>...<br><br>procedure Modulus(Number1: Integer; Divisor: Integer): Integer<br>begin<br>    // Remainder of dividing Number1 by Divisor<br>    exit(Number1 mod Divisor);<br>end;<br><br>...</pre><p>Save your changes and publish.</p><h3>Test — Calculator Service (Division)</h3><p>Once publish is complete, We will try to test the Division service and see if it still works as expected.</p><ol><li>Open your SoapUI project and click on the Division request page. Try to submit the request after filling the number parameters.</li></ol><ul><li>We get an error 500 (Internal Server Error) response as follows:</li></ul><pre>&lt;s:Envelope xmlns:s=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>&lt;s:Body&gt;<br>    &lt;s:Fault&gt;<br>        &lt;faultcode xmlns:a=&quot;urn:microsoft-dynamics-schemas/error&quot;&gt;a:Microsoft.Dynamics.Nav.Service.SOAP.ServiceBrokerException&lt;/faultcode&gt;<br>        &lt;faultstring xml:lang=&quot;en-US&quot;&gt;Parameter divisor in method Division in service CalculatorService is null!&lt;/faultstring&gt;<br>        &lt;detail&gt;<br>            &lt;string xmlns=&quot;http://schemas.microsoft.com/2003/10/Serialization/&quot;&gt;Parameter divisor in method Division in service CalculatorService is null!&lt;/string&gt;<br>        &lt;/detail&gt;<br>    &lt;/s:Fault&gt;<br>&lt;/s:Body&gt;<br>&lt;/s:Envelope&gt;</pre><h3>Handling Codeunit Updates in SoapUI</h3><p>Once updates are made on the Codeunit service, we need to retrieve the latest WSDL definition from the SOAP URL and update our SoapUI project.</p><ol><li>On the left sidebar menu, navigate to your project then right click on the <strong>CalculatorService_Binding</strong> menu item then choose the option <strong>Update Definition</strong>.</li><li>You will be prompted to check/uncheck a list of items. Proceed to enable/check the following items:</li></ol><ul><li>Create New Requests.</li><li>Recreate Requests.</li><li>Keep Existing.</li><li>Keep SOAP Headers.</li><li>Update TestRequests.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*c8V_MlE1pkVRJvX7blj_pQ.png" /></figure><ul><li>Press <strong>OK</strong> to authenticate and retrieve the updated WSDL changes into the project.</li><li>We see the new service <strong>Modulus</strong> is defined.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*5-CylbipGVHhZSYlR7-C4Q.png" /></figure><ul><li>Click on the <strong>+</strong> icon on the <strong>Division</strong> service then double click on <strong>Request 1</strong> menu. A request window is opened. Take note that the <strong>divisor</strong> parameter has been added on the request body.</li></ul><pre>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:cal=&quot;urn:microsoft-dynamics-schemas/codeunit/CalculatorService&quot;&gt;<br>&lt;soapenv:Header/&gt;<br>&lt;soapenv:Body&gt;<br>    &lt;cal:Division&gt;<br>        &lt;cal:number1&gt;16&lt;/cal:number1&gt;<br>        &lt;cal:divisor&gt;?&lt;/cal:divisor&gt;<br>    &lt;/cal:Division&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/soapenv:Envelope&gt;</pre><ul><li>Replace the ”?” value with a number value e.g. 4 then proceed to resubmit to test the service. We observe that now we get a response from the SOAP service.</li></ul><pre>&lt;Soap:Envelope xmlns:Soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;<br>&lt;Soap:Body&gt;<br>    &lt;Division_Result xmlns=&quot;urn:microsoft-dynamics-schemas/codeunit/CalculatorService&quot;&gt;<br>        &lt;return_value&gt;4&lt;/return_value&gt;<br>    &lt;/Division_Result&gt;<br>&lt;/Soap:Body&gt;<br>&lt;/Soap:Envelope&gt;</pre><p>3. We can proceed to also test the new <strong>Modulus</strong> service.</p><h3>Testing — Calculator Service (Modulus)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*TOdyHmc2xQh7mDr5GS1-nQ.png" /></figure><p>Great. That’s it for this section of testing our Business Central Web Service using SOAP UI. In the next article, we will explore how to test our Web Service using another API testing tool, Postman.</p><p>Next article…</p><p><a href="https://medium.com/@carmoseti/mb-820-series-web-services-part-3-94769f331518">MB-820 Series: Web Services (Part 3)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b13b7a93f219" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MB-820 Series: Web Services (Part 1)]]></title>
            <link>https://medium.com/@carmoseti/mb-820-series-web-services-8637df1889bc?source=rss-89ff1c016962------2</link>
            <guid isPermaLink="false">https://medium.com/p/8637df1889bc</guid>
            <category><![CDATA[dynamics-365]]></category>
            <category><![CDATA[microsoft-dynamics-365]]></category>
            <category><![CDATA[business-central]]></category>
            <category><![CDATA[mb-820]]></category>
            <category><![CDATA[microsoft-navision]]></category>
            <dc:creator><![CDATA[Carlton Moseti]]></dc:creator>
            <pubDate>Sat, 31 May 2025 15:40:47 GMT</pubDate>
            <atom:updated>2025-05-31T16:13:33.208Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get started on the MB-820 tutorial series</h3><p>The article below is part of a series of articles for the MB-820 tutorials. Click the link below to get started..</p><p><a href="https://medium.com/@carmoseti/mb-820-series-mastering-al-programming-for-microsoft-dynamics-business-central-e4025023dcde">MB-820 Series: Mastering AL Programming for Microsoft Dynamics Business Central</a></p><h3>Web Services — Setup and Definition</h3><p>Business Central allows integration and sharing of data with other systems through use of web services. Through web services other users/systems can read data from Business Central and write/send data to Business Central. Business Central supports 3 types of web services: REST, SOAP and OData:</p><p><a href="https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/web-services">Compare REST APIs, OData, and SOAP web services in Business Central - Business Central</a></p><h3>Define Codeunit — Calculator Service</h3><p>We will define a custom Codeunit <strong>Calculator Service</strong> that will be used to provide basic calculation services: <strong>Addition, Subtraction, Multiplication and Division</strong>. We will expose these functionalities through Business Central Web services.</p><ol><li>Right click on the space below the <strong>.app</strong> file and click on the first menu option <strong><em>New AL File Wizard (AZ AL Dev Tools)</em></strong></li><li>You will be prompted to <strong>Select Wizard Type</strong>. Type the word <strong><em>Codeunit</em></strong> then hit ENTER</li><li>On the wizard, We will define a new Codeunit object: <strong>Calculator Service</strong> as shown below. Once done click finish:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*Eg_dp2QlxJecsKMCBrlCRg.png" /><figcaption>Codeunit 50101 — Calculator Service</figcaption></figure><ul><li>We see that a new file <strong>Cod50101.CalculatorService.al</strong> is created.</li></ul><p>4. We will add the 4 services to the file as follows:</p><pre>codeunit 50101 &quot;Calculator Service&quot;<br>{<br>    procedure Addition(Number1: Integer; Number2: Integer): Integer<br>    begin<br>        // return the sum of Number1 &amp; Number2<br>        exit(Number1 + Number2);<br>    end;<br><br>    procedure Subtraction(Number1: Integer; Number2: Integer): Integer<br>    begin<br>        // Subtract Number2 from Number1<br>        exit(Number1 - Number2);<br>    end;<br><br>    procedure Multiplication(Number1: Integer; Number2: Integer): Integer<br>    begin<br>        // Multiply Number1 and Number2<br>        exit(Number1 * Number2);<br>    end;<br><br>    procedure Division(Number1: Integer; Number2: Integer): Integer<br>    begin<br>        // Divide Number1 by Number2<br>        exit(Number1 / Number2);<br>    end;<br>}</pre><p>5. Once done save the file and publish the changes</p><h3>Define Web Service — Calculator Service</h3><ol><li>On the top right menu, click the Search icon, then search for the list page <strong>Web Services</strong>. Click on the Web Services item to open the list page.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*neQK-I7djerfQwHYIByZqg.png" /><figcaption>Web services list page</figcaption></figure><p>2. Click on the <strong>+ New</strong> button to define our <strong>“Calculator Service”</strong>. You will see a new row item is added to our web services list. Proceed to input as follows:</p><ul><li>Object Type = <strong><em>Codeunit</em></strong></li><li>Object Id = <strong><em>50101</em></strong> (The codeunit number of the Calculator Service)</li><li>After typing the Object Id value, press TAB key. You will see that the <strong>Object Name</strong> field is autocompleted for you.</li><li>Service Name = <strong><em>CalculatorService</em></strong></li><li>Published = <strong><em>true</em></strong></li><li>Press TAB key. You will see that the <strong>SOAP URL</strong> field is populated with a link.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yu0J3sOSK5GSxS98rTIJzw.png" /></figure><p>3. Click the <strong>SOAP URL</strong> link provided:</p><ul><li>A new tab will be opened whereby you will be prompted to login.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*ydvUZvFe5RhH4x79ySUIpw.png" /></figure><ul><li>Login with your Business Central user account credentials. Once logged in successfully, we are presented with an XML response on the browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vMGfyosMf1t_GIWH-29JRA.png" /></figure><p>4. The XML response is called <strong>WSDL (Web Services Description Language)</strong> and it is used to describe the services offered by the given SOAP url.</p><p>That’s it. Congratulations on setting up your first web service. In the next article, we will proceed to test our Web Service SOAP URL endpoint using SOAP UI tool.</p><p>Next article…</p><p><a href="https://medium.com/@carmoseti/mb-820-series-web-services-part-2-b13b7a93f219">MB-820 Series: Web Services (Part 2)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8637df1889bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MB-820 Series: Codeunits]]></title>
            <link>https://medium.com/@carmoseti/mb-820-series-codeunits-1cbb58853af2?source=rss-89ff1c016962------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cbb58853af2</guid>
            <category><![CDATA[mb-820]]></category>
            <category><![CDATA[microsoft-navision]]></category>
            <category><![CDATA[microsoft-dynamics-365]]></category>
            <category><![CDATA[dynamics-365]]></category>
            <category><![CDATA[business-central]]></category>
            <dc:creator><![CDATA[Carlton Moseti]]></dc:creator>
            <pubDate>Sat, 31 May 2025 13:05:49 GMT</pubDate>
            <atom:updated>2025-05-31T15:41:11.782Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get started on the MB-820 tutorial series</h3><p>The article below is part of a series of articles for the MB-820 tutorials. Click the link below to get started..</p><p><a href="https://medium.com/@carmoseti/mb-820-series-mastering-al-programming-for-microsoft-dynamics-business-central-e4025023dcde">MB-820 Series: Mastering AL Programming for Microsoft Dynamics Business Central</a></p><h3>Codeunit — Setup and definition</h3><p>We will proceed to define AL Codeunit for our vehicle inventory system. Codeunits are objects that contain code that may be reused across other AL objects. Codeunits contain AL functions/procedures that are reusable. This allows for a single location maintenance of common business logic:</p><p><a href="https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-codeunit-object">Codeunit object - Business Central</a></p><h3>Define Codeunit — Global Functions</h3><p>We will define our custom codeunit object <strong>Global Functions</strong> that will contain reusable code that can be referenced across other objects.</p><ol><li>Right click on the space below the <strong>.app</strong> file and click on the first menu option <strong><em>New AL File Wizard (AZ AL Dev Tools)</em></strong></li><li>You will be prompted to <strong>Select Wizard Type</strong>. Type the word <strong><em>Codeunit</em></strong> then hit ENTER</li><li>On the wizard, We will define a new Codeunit object: <strong>Global Functions</strong> as shown below. Once done click finish:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*sYsaXDaMoTbcad8EO3Un3A.png" /><figcaption>Codeunit setup and definition</figcaption></figure><ul><li>We see that a new file <strong>Cod50100.GlobalFunctions.al</strong> is created.</li></ul><p>4. Our 2 table objects: <strong>“Vehicle Types”</strong> and <strong>“Vehicle Register”</strong> have similar code logic on the <strong>OnDelete</strong> trigger:</p><pre>...<br><br>trigger OnDelete()<br>var<br>    myInt: Integer;<br>begin<br>    // Confirm to proceed with deletion<br>    if not (Confirm(&#39;Are you sure you want to delete this record?&#39;)) then begin<br>        // Confirm - No<br>        Error(&#39;Record deletion has been cancelled&#39;);<br>    end else begin<br>        // Confirm - Yes<br>        Message(&#39;Record will be deleted!&#39;);<br>    end;<br>end;<br><br>...</pre><p>5. We will modify our Codeunit file and add a new procedure: <strong>ConfirmRecordDeletion()</strong> which we will reference from the 2 tables through the codeunit.</p><ul><li>Type the word <strong>tprocedure</strong> and hit enter to use the procedure snippet. AL Code snippets assist in generating the structure of various AL code objects. The <strong>tprocedure</strong> snippet will generate for you a sample procedure as follows:</li></ul><pre>codeunit 50100 &quot;Global Functions&quot;<br>{<br>    local procedure MyProcedure()<br>    var<br>        myInt: Integer;<br>    begin<br><br>    end;<br>}</pre><ul><li>Delete the <strong>local</strong> part of the procedure and rename the procedure to <strong>ConfirmRecordDeletion</strong>. Local procedures are only accessible within the code unit (locally). Since we want to access our procedure externally from our table objects, we delete the <strong>local</strong> tag.</li></ul><pre>codeunit 50100 &quot;Global Functions&quot;<br>{<br>    procedure ConfirmRecordDeletion()<br>    var<br>        myInt: Integer;<br>    begin<br><br>    end;<br>}</pre><ul><li>Copy the code logic from the <strong>OnDelete</strong> table trigger into our new procedure:</li></ul><pre>codeunit 50100 &quot;Global Functions&quot;<br>{<br>    procedure ConfirmRecordDeletion()<br>    var<br>        myInt: Integer;<br>    begin<br>        // Confirm to proceed with deletion<br>        if not (Confirm(&#39;Are you sure you want to delete this record?&#39;)) then begin<br>            // Confirm - No<br>            Error(&#39;Record deletion has been cancelled&#39;);<br>        end else begin<br>            // Confirm - Yes<br>            Message(&#39;Record will be deleted!&#39;);<br>        end;<br>    end;<br>}</pre><p>6. We’ll reference the Codeunit from the 2 table triggers and replace the logic with a call to the <strong>ConfirmRecordDeletion</strong> procedure.</p><pre>...<br><br>trigger OnDelete()<br>var<br>    GlobalFunctions: Codeunit &quot;Global Functions&quot;;<br>begin<br>    GlobalFunctions.ConfirmRecordDeletion();<br>end;<br><br>...</pre><p>Save you code changes and publish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wtg9Eye0Bp4v2J_WvPhPjQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*J08rScvIj6Ply-kro9ogtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8tJVVZZgRJ5DHaMsZOMXeg.png" /></figure><p>We have completed the brief section on <strong>Codeunit</strong> AL objects. In the next article, we’ll proceed to define Web Service integration points for our AL application. This will allow for the secure and controlled sharing of data from our AL application to other external 3rd party applications.</p><p>Next article…</p><p><a href="https://medium.com/@carmoseti/mb-820-series-web-services-8637df1889bc">MB-820 Series: Web Services</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cbb58853af2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MB-820 Series: Reports (Part 3)]]></title>
            <link>https://medium.com/@carmoseti/mb-820-series-reports-part-3-4b952d351f84?source=rss-89ff1c016962------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b952d351f84</guid>
            <category><![CDATA[dynamics-nav]]></category>
            <category><![CDATA[mb-820]]></category>
            <category><![CDATA[microsoft-dynamics-365]]></category>
            <category><![CDATA[dynamics-365]]></category>
            <category><![CDATA[business-central]]></category>
            <dc:creator><![CDATA[Carlton Moseti]]></dc:creator>
            <pubDate>Sat, 31 May 2025 12:52:30 GMT</pubDate>
            <atom:updated>2025-05-31T13:06:27.688Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get started on the MB-820 tutorial series</h3><p>The article below is part of a series of articles for the MB-820 tutorials. Click the link below to get started..</p><p><a href="https://medium.com/@carmoseti/mb-820-series-mastering-al-programming-for-microsoft-dynamics-business-central-e4025023dcde">MB-820 Series: Mastering AL Programming for Microsoft Dynamics Business Central</a></p><h3>Reports — Headers &amp; Footers</h3><p>We will add content on the header and footer sections of the report.</p><h3>Modify RDL file — Vehicle Brands</h3><ol><li>On VSCode, right click on the .rdl file then select menu <strong>Open Externally</strong> to open the RDL file in Microsoft Report Builder.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*gZoprewT4-z8fTZUZyHfYw.png" /></figure><p>2. On the Microsoft Report Builder click on the <strong>Insert</strong> tab then click the <strong>Text Box</strong> icon menu. Proceed to add the <strong>Text Box</strong> to the page header section.</p><ul><li>Add the <strong>Text Box</strong> on the right section of the header. Double click inside the text box.</li><li>On the left sidebar menu, click on the first menu <strong>Built-in Fields</strong> then select the field <strong>Report Name</strong> and drag the field into the text box.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LwnGF0cjuvGZRtbtN_u3sg.png" /></figure><p>Modify the <strong>Text Box</strong> properties as follows:</p><ul><li>Alignment -&gt; TextAlign = Right</li></ul><p>Duplicate (Copy paste) the <strong>Text Box</strong> then place the 2nd one below the first one.</p><ul><li>Clear the field data in the text box then proceed to add another Built-in Field, <strong>User ID</strong> into the text box.</li><li>While on the text box, type CTRL + I to format the <strong>User ID</strong> field in italics.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*iCIBATPHco14zb1OZ00lFw.png" /></figure><p>3. We will now add page number information on the footer section of the page.</p><ul><li>Click on the <strong>Insert</strong> tab then click the <strong>Text Box</strong> icon menu. Add the <strong>Text Box</strong> on the right section of the footer. Double click inside the text box.</li><li>Type <strong>“Page ”</strong> into the text box.</li><li>On the left sidebar menu, click on the first menu <strong>Built-in Fields</strong> then select the field <strong>Overall Page Number</strong> and drag the field into the text box.</li><li>After the added field, type <strong>” of ”</strong> into the text box.</li><li>On the left sidebar menu, click on the first menu <strong>Built-in Fields</strong> then select the field <strong>Overall Total Pages</strong> and drag the field into the text box. Format the text box with <strong>right</strong> text alignment.</li><li>Add another <strong>Text Box</strong> below the page information field. From the <strong>Built-in Fields</strong> add the field <strong>Execution Time</strong> into the text box. Format the text box in <strong>italics</strong> with <strong>right</strong> text alignment.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*XAdBIHeVyXpiCEdMU0lBDQ.png" /></figure><p>4. Save your report layout in Microsoft Report Builder.</p><p>5. Save your code and publish your changes.</p><p>6. Click on the action <strong>Vehicle Brands Report</strong> and run your report.</p><ul><li>Click the button <strong>Preview &amp; Close</strong></li><li>Header section. <strong>Report Name</strong> field may or may not be visible. <strong>User ID</strong> field is visible.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*pRjGPNSAEbeVIIFtBJWOaA.png" /><figcaption>Header Section</figcaption></figure><ul><li>Footer section.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*hUax8w_xnQHuwoOCnkIr4Q.png" /><figcaption>Footer Section</figcaption></figure><h3>Reports — Vehicle Register Per Model</h3><p>In this section, we will define a report <strong>Vehicle Register Per Model</strong> which will display the registered vehicles grouped by their non-parent vehicle type:</p><h3>Define Report — Vehicle Register Per Model</h3><ol><li>Right click on the space below the <strong>.app</strong> file and click on the first menu option <strong><em>New AL File Wizard (AZ AL Dev Tools)</em></strong></li><li>You will be prompted to <strong>Select Wizard Type</strong>. Type the word <strong><em>Report</em></strong> then hit ENTER</li><li>On the wizard, We will define a new report object: <strong>Vehicle Register Per Model</strong> and its fields as shown below. Once done click finish:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*ljbHM8vsu-mYu5YyhWeh-w.png" /><figcaption>Report setup</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*3wvIMtzACwnCQPGsjUbgiQ.png" /><figcaption>Report fields</figcaption></figure><p>4. We see that a new file <strong>Rep50101.VehicleRegisterPerModel.al</strong> is created.</p><p>5. We will modify the file as follows:</p><ul><li>Set a <strong>RequestFilterFields</strong> property value to field <strong>“Vehicle Type No.”</strong>. This will prompt the user to be requested for the vehicle model type before running the report.</li></ul><pre>report 50101 &quot;Vehicle Register Per Model&quot;<br>{<br>    ...<br><br>    dataset<br>    {<br>        dataitem(VehicleRegister; &quot;Vehicle Register&quot;)<br>        {<br>            RequestFilterFields = &quot;Vehicle Type No.&quot;;<br><br>            ...<br>        }<br>    }<br><br>    ...<br>}</pre><ul><li>Rename the <strong>VehicleRegister</strong> dataitem columns as follows:</li></ul><pre>report 50101 &quot;Vehicle Register Per Model&quot;<br>{<br>    ...<br><br>    dataset<br>    {<br>        dataitem(VehicleRegister; &quot;Vehicle Register&quot;)<br>        {<br>            RequestFilterFields = &quot;Vehicle Type No.&quot;;<br><br>            column(VehicleRegisterTypeNo; &quot;Vehicle Type No.&quot;)<br>            {<br>            }<br>            column(VehicleRegisterDescription; Description)<br>            {<br>            }<br>            column(VehicleRegisterRegNo; &quot;Registration No.&quot;)<br>            {<br>            }<br>            column(VehicleRegisterCreatedBy; &quot;Created By&quot;)<br>            {<br>            }<br>            column(VehicleRegisterCreatedAt; SystemCreatedAt)<br>            {<br>            }<br>            column(VehicleRegisterUpdatedBy; &quot;Updated By&quot;)<br>            {<br>            }<br>            column(VehicleRegisterUpdatedAt; SystemModifiedAt)<br>            {<br>            }<br>        }<br>    }<br><br>    ...<br>}</pre><ul><li>Define a new dataitem <strong>VehicleTypes</strong> as a child dataitem of <strong>VehicleRegister</strong> dataitem. The child dataitem will be linked to the parent dataitem using the <strong>DataItemLink</strong> property. The <strong>“No.”</strong> field is linked to the parent <strong>“Vehicle Type No.”</strong> field. This will allow lookup of the <strong>“Vehicle Types”</strong> list to determine the <strong>Vehicle Type (Model)</strong></li></ul><pre>report 50101 &quot;Vehicle Register Per Model&quot;<br>{<br>    ...<br><br>    dataset<br>    {<br>        dataitem(VehicleRegister; &quot;Vehicle Register&quot;)<br>        {<br>            ...<br><br>            dataitem(VehicleTypes; &quot;Vehicle Types&quot;)<br>            {<br>                DataItemLink = &quot;No.&quot; = field(&quot;Vehicle Type No.&quot;);<br>                column(No; &quot;No.&quot;)<br>                {<br>                }<br>                column(BrandName; &quot;Brand Name&quot;)<br>                {<br>                }<br>                column(Description; Description)<br>                {<br>                }<br>                column(LogoImage; &quot;Logo/Image&quot;)<br>                {<br>                }<br>                column(ParentBrandName; &quot;Parent Brand Name&quot;)<br>                {<br>                }<br>                column(RegisteredVehicles; &quot;Registered Vehicles&quot;)<br>                {<br>                }<br>            }<br>        }<br>    }<br><br>    ...<br>}</pre><ul><li>Add a property <strong><em>SaveValues = true;</em></strong> on the <strong>requestpage</strong> section of the report. This will ensure the report filter modal page is not closed after previewing and closing the report.</li></ul><pre>report 50101 &quot;Vehicle Register Per Model&quot;<br>{<br>    ...<br><br>    dataset<br>    {<br>        ...<br>    }<br><br>    requestpage<br>    {<br>        SaveValues = true;<br><br>        ...<br>    }<br>}</pre><h3>Define RDL — Vehicle Register Per Model</h3><ol><li>We will modify the file <strong>Rep50101.VehicleRegisterPerModel.al</strong> as follows:</li></ol><ul><li>Add a property <strong><em>RDLCLayout = ‘Rep50101.VehicleRegisterPerModel.rdl’;</em></strong></li></ul><pre>report 50101 &quot;Vehicle Register Per Model&quot;<br>{<br>    ...<br><br>    RDLCLayout = &#39;Rep50101.VehicleRegisterPerModel.rdl&#39;;<br><br>    ...<br>}</pre><p>2. Press the keys CTRL + SHIFT + B to build the extension and generate the RDL file: <strong>Rep50101.VehicleRegisterPerModel.rdl</strong></p><h3>Modify RDL file — Vehicle Register Per Model</h3><p>RDL files may be edited using the <strong>Microsoft Report Builder</strong> tool.</p><ol><li>On VSCode, right click on the .rdl file then select menu <strong>Open Externally</strong> to open the RDL file in Microsoft Report Builder.</li></ol><p>2. Insert an image into the page area and set its properties as follows:</p><ul><li>Image Source = Database</li><li>Field = LogoImage</li><li>MIME Type = image/jpeg</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*6pfSCTFh80OynAM0Q59dUw.png" /></figure><ul><li>BorderStyle = Solid</li><li>Width = 3in</li><li>Height = 1.5in</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*UuL5foQ6eJ-IvlaS45Qcvw.png" /></figure><p>3. Define the body/page area to have a width of <strong>8.3in</strong></p><p>4. Next to the <strong>Image</strong> object, define 4 <strong>Text Boxes</strong> as on the screenshot below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*yicvXTv46nwREIBD63YzmA.png" /></figure><p>5. Click on the <strong>Insert</strong> menu then select <strong><em>Table -&gt; Insert Table</em></strong>. Place the table object on the page area below the image and text boxes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*BDQA5lpVXF_oPKlEfB4tgg.png" /></figure><p>6. Add the available <strong>Vehicle Register</strong> columns and format the table as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*wisImGSg3cwCJrA0MJlI9g.png" /></figure><p>7. Insert a page header section on the page area and add 2 <strong>Built-in Fields</strong> as text boxes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*07Ug7OSPdzYFHU8how8Z5g.png" /></figure><p>8. Insert a page footer section on the page area and add 2 <strong>Built-in Fields</strong> as text boxes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*ayazkkkDXgozcXD8E6VCfw.png" /></figure><p>9. Save your report layout in Microsoft Report Builder.</p><p>10. Add your report in the <strong>“Vehicle Management Role Center”</strong> under the <strong><em>“Reporting”</em></strong> area:</p><pre>page 50106 &quot;Vehicle Management Role Center&quot;<br>{<br>    ...<br><br>    actions<br>    {<br>        area(Sections)<br>        {<br>            ...<br>        }<br><br>        area(Reporting)<br>        {<br>            ...<br><br>            action(VehicleRegisterPerModelReport)<br>            {<br>                Caption = &#39;Vehicle Register Per Model Report&#39;;<br>                Image = Report;<br>                RunObject = report &quot;Vehicle Register Per Model&quot;;<br>            }<br>        }<br>    }<br><br>    ...<br>}</pre><p>Save your code and publish your changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ODZSvXm4BKRPOeLB0Bs_UQ.png" /></figure><p>Click on the action <strong>Vehicle Register Per Model Report</strong> and run your report.</p><ul><li>Click the button <strong>Preview</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*PqQEqG6k1544nU0D9MKH8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*whMi2wrkyLYf8-GoTXAL6A.png" /></figure><p>Great. That’s it for a comprehensive 3-part articles detailing the setup of Business Central custom <strong>Report</strong> objects.</p><p>In the next article we will proceed to define <strong>Codeunit</strong> objects for our custom application.</p><p>Next article…</p><p><a href="https://medium.com/@carmoseti/mb-820-series-codeunits-1cbb58853af2">MB-820 Series: Codeunits</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b952d351f84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MB-820 Series: Reports (Part 2)]]></title>
            <link>https://medium.com/@carmoseti/mb-820-series-reports-part-2-8f42a29676b2?source=rss-89ff1c016962------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f42a29676b2</guid>
            <category><![CDATA[mb-820]]></category>
            <category><![CDATA[business-central]]></category>
            <category><![CDATA[microsoft-dynamics-365]]></category>
            <category><![CDATA[dynamics-365]]></category>
            <dc:creator><![CDATA[Carlton Moseti]]></dc:creator>
            <pubDate>Sat, 31 May 2025 12:13:47 GMT</pubDate>
            <atom:updated>2025-05-31T12:53:20.340Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get started on the MB-820 tutorial series</h3><p>The article below is part of a series of articles for the MB-820 tutorials. Click the link below to get started..</p><p><a href="https://medium.com/@carmoseti/mb-820-series-mastering-al-programming-for-microsoft-dynamics-business-central-e4025023dcde">MB-820 Series: Mastering AL Programming for Microsoft Dynamics Business Central</a></p><h3>Reports — Add Images</h3><p>We will add logos of the vehicle brands on the report.</p><h3>Modify RDL file — Vehicle Brands</h3><ol><li>On VSCode, right click on the .rdl file then select menu <strong>Open Externally</strong> to open the RDL file in Microsoft Report Builder.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*7PiCHkeoOf9XGEDt_-5y_Q.png" /></figure><p>2. Insert a new column <strong>Logo</strong> on the right of the first <strong>No</strong> column. Align the widths of the columns to fit the view page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*fvAh-tH2dCWWmkClX-sItQ.png" /></figure><ul><li>Select the <strong>Logo</strong> data cell and clear/delete the <strong>“[LogoImage]”</strong> value.</li><li>On the Microsoft Report Builder click on the <strong>Insert</strong> tab then click the <strong>Image</strong> icon menu. Once selected, place the <strong>Image</strong> cursor on the <strong>Logo</strong> data cell. An Image Properties menu will pop up.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*hhlv3g-nGmnEszqftAeKMg.png" /></figure><p>3. Fill the data as follows:</p><ul><li>Name = “LogoImage”</li><li>Image Source = “Database”</li><li>Field = “[LogoImage]”</li><li>MIME Type = “image/jpeg”</li></ul><p>4. Select the <strong>Logo</strong> data cell to modify its properties.</p><ul><li>On the <strong>Border -&gt; BorderColor</strong> sub-menu, set the <strong>Default</strong> color property to <strong><em>LightGrey</em></strong></li><li>On the <strong>Border -&gt; BorderStyle</strong> sub-menu, set the <strong>Bottom</strong> and <strong>Top</strong> border properties to <strong><em>Solid</em></strong></li><li>On the <strong>Position -&gt; Size</strong> sub-menu, set the <strong>Height</strong> property to <strong><em>2.5in</em></strong></li><li>On the <strong>Size -&gt; Padding</strong> sub-menu, set the <strong>Padding</strong> property values to <strong><em>8pt</em></strong> each</li></ul><p>5. Select the page/body area then navigate to the <strong>Properties</strong> menu.</p><ul><li>On the <strong>Position -&gt; Size</strong> menu set the <strong>Width</strong> of the page to <strong>8.3in</strong>. Also increase the height property to make the new row height visible on the report designer.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*QxTpRpdzrjvBKEK0A7dHkA.png" /></figure><p>6. On the Microsoft Report Builder click on the <strong>Insert</strong> tab then click the <strong>Header</strong> icon menu. Proceed to add the page header section.</p><p>7. On the Microsoft Report Builder click on the <strong>Insert</strong> tab then click the <strong>Footer</strong> icon menu. Proceed to add the page footer section.</p><p>8. Save your report layout in Microsoft Report Builder.</p><p>9. Save your code and publish your changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*gZoprewT4-z8fTZUZyHfYw.png" /></figure><p>10. Click on the action <strong>Vehicle Brands Report</strong> and run your report.</p><ul><li>Click the button <strong>Preview &amp; Close</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*ibz934bTLJW1P1FBZgJ31A.png" /></figure><p>That’s it for displaying images on our report. In the next part article on <strong>Report</strong> objects, we will define our header and footer sections for the report.</p><p>Next article…</p><p><a href="https://medium.com/@carmoseti/mb-820-series-reports-part-3-4b952d351f84">MB-820 Series: Reports (Part 3)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f42a29676b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>