Configure Web Services through Code in Business Central

Configure Web Services through Code in Business Central

olisterr No Comments

Introduction:

When coding an app that uses Webservices to connect to the integration solutions, it is generally recommended that there is a Setup, which we can configure, where the Webservices are created as well as deleted.

Pre-requisites:

  1. Business Central
  2. VS Code with AL Language Extension

Demonstration:

  1. Create a Setup Page having a boolean variable say ‘SetupExtension‘ and create a field having value as ‘SetupExtension Variable’.

    Output:
  2. On the OnOpenPage trigger add a code to Check if Web Services are already created and accordingly set the ‘SetupExtension‘ boolean field.

    Thus, whenever the Setup Page is Opened, the ‘SetupExtension‘ field is set as per the records in Web Services.
  3. On the OnQueryClosePage trigger write a code which will create the Web Services when ‘SetupExtension‘ boolean is set as ‘TRUE‘ and delete the Web Services if ‘SetupExtension‘ boolean is set as ‘FALSE‘.


    Output:
    i. When ‘SetupExtension‘ is set to ‘TRUE



    New Webservices are created.
    ii. When ‘SetupExtension‘ is set to ‘FALSE



    Web Services are deleted.

    Conclusion:

    Thus this way we can keep the existing app installed and enable/disable Web Services as needed. As compared to creating WebServices.xml file which directly creates the Web Services on installation of the app, I’ll be demonstrating it in my next blog.

Customize DED Transformation Rule in Business Central

olisterr No Comments

Introduction:

Dealing with Electronic Bank Payment Setup can be tedious and time
consuming. In this blog, I’ve a unusual requirement where the payment
date should be the next day of the check issue date. Thus we will customize Data Exchange Definition Transformation Rule in Business Central.

Pre-requisite:

Microsoft Dynamics Business Central
VS Code and AL Language Extension

Demonstration:

  1. In standard Data Exchange Definition, I didn’t find any rule to
    increment the date by 1 day. So using the Integration Event and Event
    Subscriber, I’ve written AL Code to use the custom transformation rule
    and perform the +1D operation

2. I’ve created a custom Transformation Rule in the Feild Mapping on
Data Exchange Definition in this case ‘ADD1D’ and set in the field
mapping

3. In the code I’m looking for the
transformation rule with the name ‘ADD1D’ and then use the code to
actually add 1 day to the date
Code:

4. Output:


Conclusion:

This type of customization not only can be done with Data Exchange
Definitions. This was an example of how the Integration-Event
Subscriber can be used to modify existing functionality in Business
Central

Customize Void-Check Indicator for Positive Pay in NAV/BC

olisterr No Comments

Scenario:

There is a client requirement where the Positive Pay Export has a void-check indicator which needs to be 3 Text character. Although there is 1 Text character field for Void Check Indicator in standard positive pay, I couldn’t get it to convert to the desired format by using Transformation Rules or Text Padding. Thus we’ll be Customizing the positive pay void check indicator using extensions in Business Central.

Introduction:

Positive Pay can be a very effective tool when it comes to eletronically transferring cheques and payments. As most of the banks have their predefined setup for Positive Pay sometimes this process can be painful.
One among the issues was the scenario mentioned above. Therefore here i how we solve this issues using AL Extension(that is customizations) in Business Central.

Pre-requisites:

Microsoft Dynamics 365 Business Central.
Working understanding of Positive Pay Export. Refer(https://olisterr.000webhostapp.com/2018/06/11/setting-up-a-custom-positive-pay-export-for-key-bank-in-nav-2017/)

Demonstration:

As per requirements for Santander Bank,
*26 indicates Void Check.
*10 indicates printed Check.

Whereas in standard we get,
‘V’ indicates Void Check.
‘<blank>’ indicates printed Check.

The first viable option was using transformation rules such as replace V with *26 and <Blank> with *10, the transformation rules only converts the first character which is V to * and  <Blank> to *.
Therefore there are few options left one of them is customizing by creating a new AL Extension. Heres how I did it!
1.In the field mapping, there is an existing codeunit(1704) which is used as Pre-Mapping Codeunit in Positive Pay Data Exchange Definition.

Pre-mapping codeunit in field mapping positive pay

2. Create a Table Extension for Table  1241( Positive Pay Detail)to  add a text field name ‘VoidStatusIndicator’ of size 50 and map it to the transaction type field.
Adding VoidStatusIndicator field using table extension
3. Thus using Text-to-AL which converts C/SIDE code from NAV to AL Code in Business Central, I exported the codeunit 1704(Pre-mapping codeunit)  and added the lines as follows in PrePosPayDetail function.
adding code for added field in the table

 

4. Now, map the newly added field VoidStatusIndicator in the field mapping and change the Pre-Mapping codeunit value to the ID of newly created codeunit Mapping the new field and codeunit

Output:

Before customizations the outputs were as follows

*   23137269100000000008935713384000000500710241800000010205
*   23137269100000000008935713384000000500910241800000010201

After customizations the outputs are as follows
*2623137269100000000008935713384000000500710241800000010205
*1023137269100000000008935713384000000500910241800000010201

Conclusion:

In this way we can customize Positive Pay.

In my next blog, I’ll be writing about the customization for ACH.

Workaround to ‘Edit in Excel’ functionality with Import/Export using Excel Buffer in Business Central

olisterr No Comments

Problem Definition:

When working with ‘Edit In Excel’ functionality in Business Central, there was an error( https://github.com/Microsoft/AL/issues/4060 ) when the page fields were modified using extensions.

Introduction:

Excel Buffer is one of the feature that is widely used to Import & Export data to and from Excel Sheets. With NAV evolving to Business Central, few of the existing functions are deprecated and cannot be used in AL Extensions.

Pre-requisites:

Microsoft Dynamics 365 Business Central

Demonstration:

  1. Excel Buffer Import:

In this code, total rows and columns to be imported is found, then each field is stored as ‘CellValue’ in new records in Excel Buffer. Thus, I’ve used GetValueAtIndex(Row,Column) function to get the exact ‘CellValue’.

2. Excel Buffer Export:

Conclusion:

In this blog I’ve demonstrated how to use Excel Buffer for Import/Excel of Excel from a table using AL Extensions.

NOTE: Code is located( https://github.com/olisterr/ExcelBufferImportExportforBC )

Error in ‘Amount in Words’ during Check Report Customization in Business Central? Here’s what you can do!

olisterr No Comments

Introduction:

In Business Central, the existing reports cannot be modified. Thus, for modifications in the report, the existing report is to converted to text using Text-To-Al and then modifications are to performed. But in case of Check Report(10401) it doesn’t work giving error ‘Index out of bounds!’.

Pre-requisite:

Microsoft Dynamics Business Central (Online)

Solution:

When modifying the Check Report in Business Central, the only approach available is converting existing Check Report 10401 to Text and then using Text-To-Al.Which gives the error ‘Index-Out-of-Bounds!’. Thus for a workaround I used the code from https://community.dynamics.com/nav/b/moxie4nav/archive/2014/12/08/numbers-to-words

Although this algorithm works perfectly on NAV and Business Central On Premise, it returns the same error on Business Central Online. As assumed, it was because of the recursion used.

So, here is the non-recursive algorithm that works perfectly fine up to 8 digits characteristics and 2 digits of mantissa.

List of variables:

Units[10], Tens[20], Expos[30] are arrays with respective dimensions.

Initialization of Variables:

Code:
Kindly find the text object on GitHub: https://github.com/olisterrcf/CheckReportAmountInWords

Conclusion:

While the updates are still getting generated on this issue, it is far from being conclusive to reach out to the expected results.

As per our cordial discussions with Microsoft, the existing  report objects on On-Premise versions such as NAV and Business Central On Premise are not 100% compatible with Business Central Online  which are converted using Text-To-Al tool.

In the next blog, I’ll write about update for the same.

 

Import and Export using Excel Buffers

olisterr 2 comments

Introduction:

Using XMLPort to do the Import and Export using CSV or Tab Delimited .xls can be inconvenient at times. For example when the field value contains a COMMA (First Name, Last Name) or if there are QUOTES(“”) added by Excel when saving the data. Thus the best way I found was using Excel Buffer.

Pre-requisite:

  1. Microsoft Dynamics NAV 2013 R2 and above
  2. Microsoft Office 2010 and above

Theory:

Excel Buffer Table(370) is a table that stores the data from each cell as Row,Column, TextValue, Formula and other fields in a single record. So if Excel Sheet contains 5×5 grid i.e 5 rows and 5columns then the whole data is stored in the form 10 records in Excel Buffer. The Excel sheets can have various types of visual formatting such as Bold, Italic, Underline, Font Color, Background Colour etc.

Demonstration:

1. Exporting using Excel Buffer:

Export Excel Buffer Sample Code

                 Export Excel Buffer Sample Code

i. Var ExcelBufferTable – Type Record -ID 370

ii. ExcelBufferTable.AddColumn(<Value:Text>,<IsFormula:Boolean>,<CommentText:Text>,<IsBold:Boolean>,<IsItalics:Boolean>,<IsUnderlined:Boolean>,<NumFormat:Text>,<CellType:Option>) – adds a colum of required type.

iii. ExcelBufferTable.NewRow – adds a new row to the sheet.

iv. ExcelBufferTable.CreateBookAndOpenExcel(<FileName:Text>,<SheetName:Text>,<ReportHeader:Text>,<CompanyName:Text>,<User:Text>) – creates the Excel Sheet and the Excel Program.

 2. Importing using Excel Buffer:

 

Import1 Excel Buffer

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

i. FileMgmt.UploadFile(<WindowTitle:Text>,<FileExtension:Text>) – Uploaded the file using File Management codeunit function

ii. ExcelBufferTable.OpenBook(<Filename:Text>,<SheetName:Text>) – Open the Excel Sheet passed as Excel File(.xlsx) and read the sheet with name ‘Gift Cards’.

iii. Read the sheet using ExcelBuffer

iv. Count total Rows and Columns in the Excel sheet

v. GetValueAtCell(<RowNo:Integer>,<ColumnNo:Integer>) – Read each cell using function GetValueAtCell

Conclusion:

Thus, this is how I’ve implemented Excel Buffer for Importing and Exporting Excel Sheets. The import export was performed based on the Action Buttons as required and no special objects were created. Thanks for reading and stay in touch 🙂

Setting up a custom Positive Pay Export for Key Bank in NAV 2017

olisterr No Comments

Introduction:

What is Positive Pay Export and Why its used??
Positive Pay Export is a file that is given to the bank to verify the Cheques that have been printed.
Whenever the company wants to issue any payment to Customer or a Vendor, it is done with the help of Payment Journals. After creation of Payment Journal lines, the check is printed through a Report. 

After the creation of the Check in the Bank Account there is an action called as PositivePayExport. This file is a text file and contains the information related to the Cheques printed and it is given to the bank.
Every bank has their format which is used to automatically verify the Cheques that are being issued.

Demonstration:

1. Creating a Bank Account: To issue the cheque setting up Bank Account is mandatory

  1. Setting up the Data Exchange Definitions: Data Exchange Definition is used to setup the format for Positive Pay Export.
    i. Format for Export:

    ii. Create a new Data Exchange Definition:

    iii. Creating Column Definitions: Column Definition is the sequence in which the data is to be generated as per the format.

    iv. Creating a Line Definitions:
    Line Definitions are used to map the System Fields to the fields in the column defintions. In the Line Definition there are transformation rules that are used to modify the data that is exported into the format.

    v. Create a Line Definition and Select Field Mapping:

    vi. Transformation Rules:There are some predefined Transformation Rules as well as new transformation Rules can be created. I’ve created the following transformation rules.

    vii. Creating Transformation Rules: I’ve shown the details of REPLACE transformation rule
  2.  Connecting the Data Exchange Definition with the Bank Account: To link the Positive Pay Export and the Bank Account, goto Bank Accounts and select the Positive Pay Export Code.
  3. Creating Payment Journal Entries, Printing Cheques and Exporting the Positive Pay file.i. Creating Payment Journal Entry

    ii. Printing the Check Report
    iii. Positive Pay Export in Bank Accounts KEY4679

Conclusion:

After Exporting Positive Pay Export the values generated in TXT file as follows

000003296812746790000000012201805150000010200
000003296812746790000000013201805150000010512

This text file is given to the Key Bank to verify check payment.

Building a bottle light for the balcony part -1

olisterr One comment

Densing the climber framework for the garden

olisterr No Comments

Cleaning the window hanging money plant

olisterr One comment

www.000webhost.com