Posts

Showing posts from 2022

Recurring Sales in Business Central

Image
Introduction In this blog, we’ll be looking at how to reduce manual work in creating Sales Line in Business Central. For this, we’ll be using the Out of the Box feature of “Recurring Sales Lines.” Pre-requisites Business Central OnPrem or Cloud References Standard Recurring Sales - Microsoft Docs Configuration Search for Recurring Sales Lines in Business Central global search and then click on New. Enter a Code for Identification, a short description and the Currency Code, if applicable. In the Lines, enter the Sales Line which are to be re-created. You can also define a Quantity if you want, it can be easily over-written if necessary. Go to the Customer Card for whom the Recurring Sales Line we created is going to be applicable. Then Go to Related > Sales > Recurring Sales Lines. Set the Code of the Recurring Sales Line, we just created and set the Valid From and Valid to Dates. The Insert Rec. Lines have the following options which have the following impact:  Manual - Syst...

Adding Edit in Excel for Custom Listparts

Image
Introduction Business Central provides us an easy method of modifying our data from within Excel using Web Services commonly found in the Edit in Excel action. This can be seen in the commonly used List Pages for example Payment Terms. However this functionality can be missing for certain pages or you might want to have additional logic or filtering before executing this. For this I’ll be demonstrating how to add the “Edit in Excel” action in Business Central pages. Pre-requisites Business Central Cloud References Viewing and Editting in Excel - Microsoft Docs Configuration In the above piece of code, I’ve added the “Edit in Excel” action onto the Blanket Sales Order SubForm to allow for easily adding lines using Excel. Firstly, we define the filters that we will be using on the page that we will be passing in the “EditWorksheetInExcel” procedure of the “OdataUtility” codeunit. Note that these filters are defined as Odata expressions as the “Edit in Excel” functionality uses Excel behi...

Caching in Business Central

Image
References Data Access - Microsoft Docs Select Latest Version - Microsoft Docs Explanation Caching is one of the methods which systems use to improve performance and respond to requests rapidly. In a Business Central system, caching is done at two levels: Business Central Server Instance Data Cache. SQL Server Data Cache. Whenever a User requests data from Business Central, it firsts check whetherThe data is available in the Server Instance’s cache, If not, then it checks the SQL Server Data Cache, And if not here then it fetches the data from the database. The Business Central Server Instance’s Cache is accessible to all the Users connected to that Server Instance. There are two types of cache stored here,Global Cache Private Cache Global cache is the one which is accessible to all the Users connected to the SQL Server. Private cache is only accessible over a transaction, for a particular User, for a particular company. This cache is cleared as soon as the transaction is completed. Wh...

Apply Multiple Entries to Each Other in AL

Image
Introduction While trying to implement a functionality of automatically applying any open invoices for a Customer with the open Payments for the said customer; I observed that there was no quick and easy method to post the application directly. This can be very useful in environments where Payment Entries are created via Integrations without specifying the invoice it needs to be applied to. I read around online but couldn’t find any blogs with the latest method of doing so in Business Central. As such, I spent a good portion of my day debugging the process of applying entries, from start to end as written by Microsoft and to save your time I’m going to jot down my findings here. Pre-requisites Business Central OnPrem/Cloud Configuration Here as an example I’m using a processing report to iterate over all the open Payments in the system and the indented dataitem will iterate over all the open Invoices of the same Customer. The method of iteration and validations may vary however the gen...

Using Postman for Automated Testing

Image
Introduction While using Business Central Web Services or APIs, we often use POSTMAN for testing the request and the responses. Today we’ll see how we can automate this testing to a certain extent using the inbuilt features of POSTMAN. We can have testing logic that runs before every request, after every request or logic that tests on particular request. In the below demonstration, we’ll write automated test to check for GET, PUT, POST and DELETE operations for a single record on a custom API. Postman itself provides a bunch of standard procedures or boiler plate code which we can modify as per our requirements. As this uses Javascript we can also use additional JS features here. Pre-requisites Account in Postman Business Central OnCloud/OnPrem Configuration POST Request So first we are going to be creating a record in the Customer Table with the following fields. One of the common things to be testing with Custom APIs is to verify whether the request is being created successfully (1) ...

Block Items on POS

Image
Introduction LS Central has its own unique way of preventing Items from being sold which is different from the standard “Blocked” option field we get on the Item Card. It also comes with detailed and refined permissions which can fit most business needs. All of this is done using another related table known as “Item Status” Pre-requisites Business Central OnCloud/OnPrem LS Central v16 References LS Retail Documentation How to block Items from POS Configuration Open the Retail Item Card for the Item you want to block. Open the “Item Status” for that Item. Click on the “Status Code” and Click on “Select from full list” Create a new record with code “BLOCKED” and enable all the fields. Here, you can see all the detailed controls available. Conclusion Thus, we saw how we can Block Items on POS in LS Central and other finer controls available at our disposal in LS Central. Happy Coding!

Use Dialogs to enhance User Experience

Image
Introduction We’ve all faced situations where we’ve had an operation take a long while which made the User wonder whether the system is stuck with something or is still processing. We can use simple dialogs which can enhance the User experience by showing User the progress of the operation. Some Business Central operations have out of the box dialogs which indicate progress like Posting documents or entries, Running reports with large data sets. Pre-requisites Business Central OnCloud/OnPrem References Dialog Data Type Configuration While using the Dialog for creating windows, there are 3 procedures that we are going to be using. Open - It creates the window which we will be displaying the messages in. Update - It updates the content of the window based on the values that we pass in it. Close - It closes the window. We can create a simple Progress Window using the below piece of code. And this is the result for it. Please note that because there were two # in the Label, system has b...

Using Task Scheduler in Business Central

Image
Introduction In Business Central, we can use Task Schedulers to use background processing to ensure that Users are not bothered with long operations. Task Scheduler provides us an easy to use and monitor way to offload tasks from the main thread. It creates separate sessions for processing and it allows creating multiple sessions which can be used to run tasks in parallel. It also allows us to define the company in which the processing will happening which is useful when we have to perform operations across all available companies, for instance initialization of certain fields or creation of certain records on application installation. Pre-requisites Business Central OnCloud or OnPremise References Task Scheduler Data Type Task Scheduler Configuration The following procedures are available for the Task Scheduler data type: CanCreateTask() - Checks whether it is possible to create a new task in this session. CreateTask() - Creates a new task with the specified codeunit, we also specif...

Using Enhanced Mailing Functionality in Business Central

Image
Introduction With SMTP Mail being deprecated, Business Central now provides us with a new and enhanced way for writing custom logic to send emails. To use this new functionality you have to first configure Email Accounts in Business Central, which you can find here . Pre-requisites Business Central v20 References Developing with enhanced mail feature Configuration The new method uses the Email Message (ID: 8904) and Email (ID: 8901) Codeunits.  I’ve added multiple actions below and I’ll be describing what the expected behaviour is. This is the simple piece of code which sends an email with the specified Recipients, CCs and BCCs. We can specify multiple recipients and dynamically as the lists are not bound by size. We can also call a simpler version of this method, where we don’t need to specify the CC and BCC. Using the OpenInEditor procedure of Email codeunit causes a page to be opened up where you can edit the message before you send it. You can also add attachments or you can sa...