Sunday, 27 February 2022

Apply multiple invoice entries against a payment entry through APIs in D365 Business Central


Step 1: Get the Payment Journal Batch that we want to use in Business Central

We can get Payment Batch details using vendorPaymentJournals API

 

{

  "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/8f0f6868-04b3-4834-8f54-49b21664eb18/Sandbox/api/v2.0/$metadata#companies(e93b67c5-78f1-ea11-bb43-000d3a2e8412)/vendorPaymentJournals",

  "value": [

    {

      "@odata.etag": "W/\"JzQ0O0R2KzNtQjdWREIybjJRRnV5b1hFVG44b3NqNlZqbDVVWVNHUWtQNzZ4L2c9MTswMDsn\"",

      "id": "30e08afa-78f1-ea11-bb43-000d3a2e8412",

      "code": "CASH",

      "displayName": "Cash receipts and payments",

      "balancingAccountId": "00000000-0000-0000-0000-000000000000",

      "balancingAccountNumber": "10100",

      "lastModifiedDateTime": "2020-09-08T02:14:48.853Z"

    },

    {

      "@odata.etag": "W/\"JzQ0O0k4MlhkK29tK0w3STdOVE40dzdZRHhuTHNpSnppVTVJVWcxRTcvdjNSOWs9MTswMDsn\"",

      "id": "32e08afa-78f1-ea11-bb43-000d3a2e8412",

      "code": "GENERAL",

      "displayName": "GENERAL",

      "balancingAccountId": "00000000-0000-0000-0000-000000000000",

      "balancingAccountNumber": "10100",

      "lastModifiedDateTime": "2020-09-08T02:14:48.86Z"

    },

    {

      "@odata.etag": "W/\"JzQ0O3pzQXAxMGt6bFVDN3ZUSlJQY1I0Zk0rOEFBY1NUUVhQM2dqelFqTEZHNEU9MTswMDsn\"",

      "id": "34e08afa-78f1-ea11-bb43-000d3a2e8412",

      "code": "PMT REG",

      "displayName": "Bank Reconciliation",

      "balancingAccountId": "00000000-0000-0000-0000-000000000000",

      "balancingAccountNumber": "CHECKING",

      "lastModifiedDateTime": "2020-09-08T02:14:48.87Z"

    }

  ]

}

I am going to use General Batch from the above list

      "id": "32e08afa-78f1-ea11-bb43-000d3a2e8412",

      "code": "GENERAL",

 

 

Step 2: Create a payment entry in Payment Journal using APIs

We can use vendorPayments API for this along with vendorPaymentJournals API

 

Body of the Post command

{

  "journalId": "32e08afa-78f1-ea11-bb43-000d3a2e8412",

  "vendorNumber": "10000",

  "documentNumber": "323",

  "externalDocumentNumber": "125",

  "amount": 2000,

  "description": "apply entries"

}

 

Response

 

{

  "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/8f0f6868-04b3-4834-8f54-49b21664eb18/Sandbox/api/v2.0/$metadata#companies(e93b67c5-78f1-ea11-bb43-000d3a2e8412)/vendorPaymentJournals(32e08afa-78f1-ea11-bb43-000d3a2e8412)/vendorPayments/$entity",

  "@odata.etag": "W/\"JzQ0O1ZCVUNIQVVGTnBEM2l4aHVIOUZzczg0a0crNlh2TTlvQVpGbXJoZVBHR1E9MTswMDsn\"",

  "id": "b3897612-e097-ec11-80f1-002248290747",

  "journalId": "32e08afa-78f1-ea11-bb43-000d3a2e8412",

  "journalDisplayName": "GENERAL",

  "lineNumber": 10000,

  "vendorId": "c6ec91f4-78f1-ea11-bb43-000d3a2e8412",

  "vendorNumber": "10000",

  "postingDate": "2022-02-27",

  "documentNumber": "323",

  "externalDocumentNumber": "125",

  "amount": 2000.00,

  "appliesToInvoiceId": "00000000-0000-0000-0000-000000000000",

  "appliesToInvoiceNumber": "",

  "description": "apply entries",

  "comment": "",

  "lastModifiedDateTime": "2022-02-27T15:15:18.987Z"

}

 

 

We can find the Payment entry in Business Central page

 


 

Step 3: Apply the above payment against multiple existing invoices in Business Central

We can get the open Vendor Entries details using applyVendorEntries API along with above VendorPaymentJournals and vendorPayments

 

{

  "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/8f0f6868-04b3-4834-8f54-49b21664eb18/Sandbox/api/v2.0/$metadata#companies(e93b67c5-78f1-ea11-bb43-000d3a2e8412)/vendorPaymentJournals(32e08afa-78f1-ea11-bb43-000d3a2e8412)/vendorPayments(b3897612-e097-ec11-80f1-002248290747)/applyVendorEntries",

  "value": [

    {

      "@odata.etag": "W/\"JzQ0O0FuSldSUCt1NHhvY044aThWZjhicUI5T2RmYWxuYmhDNFhDVE9zdnZzSm89MTswMDsn\"",

      "id": "ce27de32-4514-eb11-bbf7-000d3a9b9997",

      "applied": false,

      "appliesToId": "",

      "postingDate": "2020-04-06",

      "documentType": "Invoice",

      "documentNumber": "108211",

      "externalDocumentNumber": "107215",

      "vendorNumber": "10000",

      "vendorName": "",

      "description": "Invoice 107215",

      "remainingAmount": -1069

    },

    {

      "@odata.etag": "W/\"JzQ0O29NSkJma2tXQWNPOUdBd2RtVExLZHVxdXRaMjQ0c1JabEJaeE1rM0NqNjg9MTswMDsn\"",

      "id": "d7dd2968-5514-eb11-bbf7-000d3a9b9997",

      "applied": false,

      "appliesToId": "",

      "postingDate": "2020-04-06",

      "documentType": "Invoice",

      "documentNumber": "108212",

      "externalDocumentNumber": "107216",

      "vendorNumber": "10000",

      "vendorName": "",

      "description": "Invoice 107216",

      "remainingAmount": -690

    },

    {

      "@odata.etag": "W/\"JzQ0OzcvcU1pSDZMRkZjR1BqbjNOdDllSnhSY1lMOXAyS2w1TlBudzU1T1FCd0E9MTswMDsn\"",

      "id": "a4145e6f-5514-eb11-bbf7-000d3a9b9997",

      "applied": false,

      "appliesToId": "",

      "postingDate": "2020-04-06",

      "documentType": "Invoice",

      "documentNumber": "108213",

      "externalDocumentNumber": "107217",

      "vendorNumber": "10000",

      "vendorName": "",

      "description": "Invoice 107217",

      "remainingAmount": -460

    },

    {

      "@odata.etag": "W/\"JzQ0OzFmdG5obUdMOFhzV1NOSjFpaS9zR1psM2ZuRUxTNncxbnJCaVVDYkQrR1k9MTswMDsn\"",

      "id": "3a6bed91-8714-eb11-bbf7-000d3a9b9997",

      "applied": false,

      "appliesToId": "",

      "postingDate": "2020-04-06",

      "documentType": "Invoice",

      "documentNumber": "108214",

      "externalDocumentNumber": "107218",

      "vendorNumber": "10000",

      "vendorName": "",

      "description": "Invoice 107218",

      "remainingAmount": -230

    },

    {

      "@odata.etag": "W/\"JzQ0O1pEOWpLU0JFS3k5SnEwdzc3Z0VOL21ZTEZub1BRRTlZZStOT0g1aTJmRTQ9MTswMDsn\"",

      "id": "15c60da4-8714-eb11-bbf7-000d3a9b9997",

      "applied": false,

      "appliesToId": "",

      "postingDate": "2020-04-06",

      "documentType": "Invoice",

      "documentNumber": "108215",

      "externalDocumentNumber": "107219",

      "vendorNumber": "10000",

      "vendorName": "",

      "description": "Invoice 107219",

      "remainingAmount": -230

    },

    {

      "@odata.etag": "W/\"JzQ0O21VcEpndldlenZRdG1teXllbi9OcGRUQnFSWmVldlBwVDBFejlBVFkrYnc9MTswMDsn\"",

      "id": "d6366f3e-8a14-eb11-bbf7-000d3a9b9997",

      "applied": false,

      "appliesToId": "",

      "postingDate": "2020-04-06",

      "documentType": "Invoice",

      "documentNumber": "108216",

      "externalDocumentNumber": "107220",

      "vendorNumber": "10000",

      "vendorName": "",

      "description": "Invoice 107220",

      "remainingAmount": -230

    },

    {

      "@odata.etag": "W/\"JzQ0O1hzNHhuSWdFU2U5NHI3dXd5dEJZdzg5VXh0MmM1QnRrajg4Qm5SQlluMDQ9MTswMDsn\"",

      "id": "a8e34451-8a14-eb11-bbf7-000d3a9b9997",

      "applied": false,

      "appliesToId": "",

      "postingDate": "2020-04-06",

      "documentType": "Invoice",

      "documentNumber": "108217",

      "externalDocumentNumber": "107221",

      "vendorNumber": "10000",

      "vendorName": "",

      "description": "Invoice 107221",

      "remainingAmount": -230

    }

  ]

}

 

Now, I would like to apply the above payment against invoices 108211 and 108212 which have remaining about as 1069 and 690 respectively.

 

Before that let’s check the apply entries page in Business Central

 



Now call the below Patch APIs

https://api.businesscentral.dynamics.com/v2.0/8f0f6868-04b3-4834-8f54-49b21664eb18/Sandbox/api/v2.0/companies(e93b67c5-78f1-ea11-bb43-000d3a2e8412)/vendorPaymentJournals(32e08afa-78f1-ea11-bb43-000d3a2e8412)/vendorPayments(b3897612-e097-ec11-80f1-002248290747)/applyVendorEntries(ce27de32-4514-eb11-bbf7-000d3a9b9997)

 

Don’t forget to add header “If-Match” as *

 



Body as

{

  "applied": true

}

Response:

{

  "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/8f0f6868-04b3-4834-8f54-49b21664eb18/Sandbox/api/v2.0/$metadata#companies(e93b67c5-78f1-ea11-bb43-000d3a2e8412)/vendorPaymentJournals(32e08afa-78f1-ea11-bb43-000d3a2e8412)/vendorPayments(b3897612-e097-ec11-80f1-002248290747)/applyVendorEntries/$entity",

  "@odata.etag": "W/\"JzQ0O2szUE5KRGVUeXZ3VVQzK0U5RE5KaFFlN3BobGFBL0YyRmVmSlBmR3lLcTA9MTswMDsn\"",

  "id": "ce27de32-4514-eb11-bbf7-000d3a9b9997",

  "applied": true,

  "appliesToId": "323",

  "postingDate": "2020-04-06",

  "documentType": "Invoice",

  "documentNumber": "108211",

  "externalDocumentNumber": "107215",

  "vendorNumber": "10000",

  "vendorName": "",

  "description": "Invoice 107215",

  "remainingAmount": -1069

}

 

Now verify in Business Central

Applies-to ID field will have Payment Document No. field



Execute 2nd API call with 2nd Invoice

https://api.businesscentral.dynamics.com/v2.0/8f0f6868-04b3-4834-8f54-49b21664eb18/Sandbox/api/v2.0/companies(e93b67c5-78f1-ea11-bb43-000d3a2e8412)/vendorPaymentJournals(32e08afa-78f1-ea11-bb43-000d3a2e8412)/vendorPayments(b3897612-e097-ec11-80f1-002248290747)/applyVendorEntries(d7dd2968-5514-eb11-bbf7-000d3a9b9997)

 

Response:

{

  "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/8f0f6868-04b3-4834-8f54-49b21664eb18/Sandbox/api/v2.0/$metadata#companies(e93b67c5-78f1-ea11-bb43-000d3a2e8412)/vendorPaymentJournals(32e08afa-78f1-ea11-bb43-000d3a2e8412)/vendorPayments(b3897612-e097-ec11-80f1-002248290747)/applyVendorEntries/$entity",

  "@odata.etag": "W/\"JzQ0O2x2eGF3aFBCeTl3WjlSZ1RrbUQrc09GSGVVZEZ6RmozM0NoL3pvQk11YlU9MTswMDsn\"",

  "id": "d7dd2968-5514-eb11-bbf7-000d3a9b9997",

  "applied": true,

  "appliesToId": "323",

  "postingDate": "2020-04-06",

  "documentType": "Invoice",

  "documentNumber": "108212",

  "externalDocumentNumber": "107216",

  "vendorNumber": "10000",

  "vendorName": "",

  "description": "Invoice 107216",

  "remainingAmount": -690

}

 

Verify in Business Central.



Second invoice line also has Applies-to ID as payment document no.

 

Step 4: Post the payment journal in Business Central

 



 

Go to Vendor Ledger Entries and verify the application

Payment Entry



Click on Applied Entries

 



Notice that 2 invoices are applied to the payment

 



 

Friday, 31 December 2021

Restrict access to D365 Business Central Environments


We will learn how to restrict access to D365 Business Central Environments for users.

Ex: if we have a user ‘A’ and we would like to provide access to only Sandbox environments and not to Production environment.

 

First, go to Office 365 admin center


 

Go to “Active teams & groups” under “Teams & groups”

 


Click on “Add a group”

 


Select Security

 


Click Next

 

Provide a Name and Description

 


Click Next

 

Review the group details

 


Click on Create group

 

New group is created

 


Click Close

 

Go to Security tab and select the newly created Security group.

 


Click on Add group owner

 

Click on Add Owner again in next screen

 


Select user and click Add

 


Select Members tab and click on View all and manage members

 


Click Add members

 

Select user and click Add

 

Follow same steps and create new security group with name “Production” but do not add any members or do not add member whom we added in ‘Sandbox” security group.

 


Go to Dynamics 365 Business Central admin center

 


Select the environment to which you want to assign the newly created group.

 


Go to Security Group and click on Define

 

Select the newly created Security Group

 


Click Save

 

Click Yes on confirmation message

 


Go to Production environment and setup “Production” Security group.



Now login to Production environment and notice below error

 


Tuesday, 30 November 2021

Copying environments of different types

Copy an Environment:

1.  We can create an environment that is a copy of an existing environment, such as a sandbox that is based on production for troubleshooting.

2.  Creating production environment that is based on a sandbox, for example. When you create an environment as a copy of another environment, the new environment is created on the same application version as the environment that you are copying. 

Note: The new environment will contain all per-tenant extensions and AppSource extensions that are installed and published in the original environment that is being copied.


To copy an environment

1.     Select Environments, then select the environment that you want to copy.

2.     On the Environment Details page, choose the Copy action.

3.     In the Copy environment pane, specify the type of environment that you want to create based on the current environment.

4.     Specify a name for the new environment.

5.     Choose the Create action.




At the different stages of implementation, testing, support, and maintenance of a Business Central tenant, Business Central online now provides admins with more flexibility when they work with multiple environments.

In earlier versions, you could copy a production environment to a sandbox environment in the Business Central admin centre.

This release wave adds support for copying the environments within and across different environment types as shown in this list:

·        Sandbox to sandbox

·        Sandbox to production

·        Production to production



a.     Sandbox to Sandbox: 

          


 




 

     

b.     Sandbox to Production:

 





 

C. Production to Production

       Similarly, we can copy Production to Production


Sunday, 21 November 2021

How to Restart D365 Business Central Environment

 

In NAV days, we have possibility to restart service tier and there are many reasons for the need of having restart option.

How to restart D365 Business Central environment?

Navigate to Dynamics 365 Business Central.


Click on the environment that you want to restart

Environment Details page will open


Click on Sessions

Manage sessions page will open


Click on Restart Environment.

Click yes on below confirmation message


If we go to details screen of environment then we can notice the status “Restarting”


After sometime status will be changed to “Active”



Active sessions will get below notification



I would expect a different notification than the regular notification to have clear message.

 

 


Monday, 15 November 2021

Application Insights instrumentation key to Application Insights connection string

 

Monitoring and Analyzing Telemetry is one of the powerful features of D365 Business Central.

We must enable Application Insights to Send Telemetry to Azure Application Insights.

Please go through below Microsoft Docs link for details

EnableSending Telemetry to Application Insights - Business Central | Microsoft Docs

 

I have noticed below Notification on my environment.

The environment uses an Application Insights instrumentation key. Change it to an Application Insights connection string. Go to Enable Sending Telemetry to Application Insights for more information.

 


Earlier We must have used only Application Insights instrumentation key to enable this feature to send telemetry in Dynamics 365 Business Central admin center but now we must use Application Insights connection string.

 

How and where to get this Application Insights connection string?

 

Sign in to the Azure portal

Search for Application Insights



Click on the Application Insights which we have used/created earlier.

“Connection String” will be available under the instrumentation key

Use “Copy to Clipboard” to copy full string.

 


Go back to Dynamics 365 Business Central admin portal and open the Environment which has this notification

Click on Modify link of Application Insights connection string

Make sure that Enable Application Insights is enabled.

Enter the Connection string that we copied from Azure portal.



Click on Save

Now the notification will be gone after refreshing the environment.