D365 Business Central – How to work with “Lot No.” in Business Central
In today’s blog, we are going to discuss about “Lot No.” feature in Business Central and how to assign the Lot No to newly created Item and cerate Purchase & Sales transaction.
The very first step is to create an Item in the Item Master.
- Go to Item List page in Business central.
- Select New from the Action.
3.Select ITEM TEMPLATE
- Fill the Description field and Type field should be Inventory, here I’m using item name as Bottle.
- In the same Item card page under Item Tracking section, select LOTALL for Item Tracking Code field.
After this go back and check the item list, our new item will have been created.
The second step is to create a Purchase Order for the newly created Item
- Go to Purchase Order in Business Central
- Select New, fill the required fields.
- Under Lines
- Select the newly created item, fill required fields remember to specify the Location Code.
3.In Line action select Item Tracking Lines, item tracking page will open.
4.If the Lot No is already specified in the Item page, specify the quantity, and go to Process action select Assign LOT No.
5.If not, in lines create LOT No. and assign the quantity.
6.LOT No. are created based on the quantity assigned in the purchase order.
7.For example: – For the item Bottle, if we specify the quantity as 5 single LOT No. is created for all the 5 quantities.
Or we can create two more LOT Nos by distributing quantities between those two Lot Nos as shown below, but quantity should not exceed the original quantity.
8.Close and Post the Purchase order.
9.Now in the inventory we have Bottle of quantity 5 reserved and can be identified by the Lot No given.
10.Suppose if we want to sell those reserved quantities, Sales Order should be created.
The third step is to create a Sales Order for the newly created Item
- Go to Sales Order
- Select New, fill the required fields
- Under Lines section, select the newly created item and fill the required fields
- In the lines fill Location code same as posted purchase order. For example: Suppose location code in purchase order is Main it has to be same for sale order.
- Under Lines section, go to Related Information, under that select Item Tracking Lines.
- Select Entries a page will open, select the LOT No. and then click OK.
- Come back from Item Tracking Lines page
- Now Lot No. is allotted for the item, and we can post the Sales Order.
For more details kindly visit our linkedin page:
https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/mycompany/
By Vinyas. S.
Business Central-Understanding FlowFields
Overview
FlowFields are the fields which are used only to display the result of a calculation based on the “calcFormula” property. They are not the physical fields, as they do not store any value in the database. Interestingly, the values in the flowFields exists only at runtime. By default, the flowfields are initialized to 0. There are seven (7) types of flowFields, namely, sum, average, exist, count, min, max and lookup.
We define a flowField by defining the fieldClass property as FlowField and giving the calcFormula property as per our requirement.
Below, we have defined a flowField, “Name”, which is used to display the name of the customer. Here we have created the flowField of type “lookup”.
When the FlowField is the direct source of expression of a control on page, then FlowField is updated automatically based on calcFormula property when the page is displayed.
Now, if a flowfield is initialized to 0, how do we update the value of that flowfield? The answer to this question is using CalcFields Method.
Let us learn about the calcFields method.
CalcFields
This method is used to update the value of a flowfield. As we know that FlowFields have calcFormula property. CalcFields use the current filters and perform the calculations defined in the calcFormula property and updates the value of the flowField.
Let us make use of this calcFields in our code,
- We will define a procedure which shows us balance (flowField) of a customer.
- Firstly, we will use Record. Get () method to retrieve the record from customer table, based on the primary key field.
- Now the balance is a flowField, If we don’t update it (without using calcFields) then it will show the balance as 0.
CODE: –
OUTPUT: –
- So, we will use the calcFields method for updating the value of this flowField.
- Now Balance has some value to display, based on calcFormula.
- We will now use message () to display the Balance.
CODE: –
OUTPUT: –
For more details kindly visit our linkedin page:
https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/mycompany/
By Harshit. T.
How to create Barcode Report in Business Central
Let’s see how we can create a Barcode Report in Business Central!
So, what is a Barcode?
Barcodes are the labels, used to display information related to products. Barcode consists of two key components: Barcode provider and encoder.
Barcode provider includes different fonts and symbology available for use and Encoder are components of the provider that encode the data strings of a report dataset to a specific font specification and symbology.
How to create Barcode report!
Create a new report, if you don’t know no how to create a report please refer my previous blog I have explained how to create a report.
In “OnAfterGetRecord” trigger:
- First create “Barcode Font” variable of type “interface”, “Symbology” variable of type Enum and “String” variable of type Text.
- Assign value for Barcode Font variable, specifies which Font has to be used, Example: “IDAutomation1D”
- Assign value for Symbology that specifies variable length barcode that can be encoded, Example: Code 39 (consist up to 43 alphanumeric character)
- Assign the value for variable “String”, which specifies which string needs to be converted into a barcode.
- Create a global variable of “Text data type” and pass the value to it by encoding the String and Symbology value.
This is how it looks.
Save the report, then design the RDLC layout, refer my previous blog to know how to design the layout.
Right click on the EncodeText variable in the layout click on “Text Box Properties” click on “Font” specify the Font as IDAutomationHC39M, then click “OK” save the report and close it.
Run the report in VS code, Business central page will open search for your report and then click on the “Preview” action.
Result of the report will look like this.
For more details kindly visit our linkedin page:
https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/mycompany/
By Manasa. D.
How to create a Report Extension to add a field to the dataset of a Report
Overview
In the report extension, you can extend existing reports, similar to tables and pages.
Some of the features in the report extension –
Adding columns to the existing Dataitem.
Adding new Dataitem.
Adding a new layout file which reflects with new fields of report extension.
Adding fields in the request page.
For instance:
Let’s add a field in the Sales Invoice NA report 10074.
Add a field [HalfQty] in the existing report.
First, we need to create new “al file” for report extension. In the file, we can use report extension snippet “treportext” to create report extension object.
Then we give ID and NAME for our report extension object and add a field [HalfQty] in the dataset.
Report extension layout:
Next step is to add a layout file to the report extension. Because when we add the property [Rdlc Layout / Word Layout] to report extension, then it automatically creates a layout file of report extension, which will be empty, so we will not use this recreated file, but instead we will use a base layout file.
So, how to find a base layout file!
We need to go to “Business Central” and search the “Report Layout Selection” page and then filter it on “REPORT ID[10074]” as shown below.
Now we will add a new “Custom Layout” for the report, that’s a copy of Built-In Layout (Same as shown in below):
Click on the “Custom Layouts” and Open the Page then select the “New”.
Once when we click on “OK”, It will Create a copy of Build-In Layout. (As shown on above).
Now we can “Export” it (As shown in below).
Then file [.rdlc] is download and now we need to the move exported file [Copy of Build-In Layout] in our Vs-Code project folder and rename it to “SalesInvoiceNAExt.rdlc” (As per choice):
And now we are adding our field in the layout file. So, we will Compile “Ctrl+Shift+B” in the project, then new added field “HalfQty” in the dataset of the report extension will also be added in the rdlc layout.
When we open the rdlc layout in Vs-Code, we will have the updated dataset and Copy of Build-In layout:
Next, we need to publish the project [App] in BC.
Update the New [Copy of Build-In] Layout in Business Central:
Now we will again open the “Report Layout Selection” page and deploy our new layout in Business Central.
Go to “custom layout page” then “Import Layout” and after import then Update it (as shown in below):
After updating, the layout is showed in the page, set this layout as a default layout in this page because the layout of report extension is not updated automatically.
Always make sure to choose “Default Report Layout”, once done, then test it.
For more details kindly visit our linkedin page:
https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/mycompany/
By Aditya. D.
How to create a Card Type Page in Business Central
Overview
The main purpose of the card type page is to display the records from a table and we can choose the fields which we want to show on the card page. We design the card pages when we want to give user the freedom to view, create and modify the records of a table.
The card type of page is typically associated with List the of page which uses the same table as card page. Difference is that list pages provide an overview of all records in a table while card page gives us information about a single record in that table.
When a user selects a record from List page then it usually opens the card page for that record, allowing the user to view and modify the fields of that record. In most cases we use the card page for the master data.
Let’s Design our First Card Page using VS Code!
- The very first step for designing a card type page is defining “PageType” property as Card and giving the source table for card page.
2.After that, in layout section and inside area (Content), we can choose the fields which we want to show on the page. We can divide the fields in groups/FastTabs in an optimized way, such that the user can browse through field in effective manner.
3.We can also add “FactBox” on a card type page. Like here, we have added a part in “FactBox” showing customer ledger entry details.
- Now Let’s add an action on our card type page. Like here we have provided an action on card type page of a customer which will directly open a sales order page for creating a sales order.
5.Now that we have designed our First Card Page, to see how it looks, we have to publish it.
- As we added our action in New (PromotedCategory), we will now click on new to find our action which we created.
For more details kindly visit our linkedin page:
https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/mycompany/
By Harshit. T.
How to create a Process Only Report in Business Central
- Sometimes when you have to write a lengthy code just to open some specific table and retrieve the data from that table, that is when Process Only report comes into picture.
- With report data modeling structure, we can do that task in a simple way.
- We can create some functionality may be by using code unit objects and also by programming with the help of filters, loops, request pages…etc.
- By using ‘Process Only report’ available in Business Central we can avoid writing complex or lengthy codes in visual studio code.
Let’ see how to create simple process only report with one example.
- We can create process only report with or without using ‘Request Page’.
- But it doesn’t need any layout design.
- So, to create ‘Process only Report’, open visual studio code type ‘treport’ and select report snippet.
- Give the proper ID and name.
- In the next step, give the proper caption for the report, set ‘ProcessingOnly propert’ to ‘true’ and set ‘UseRequestPage’ property to false or true according to your need.
Caption = ‘Report Caption’;
ProcessingOnly = true;
UseRequestPage = false;
- Here I’m creating a ‘Process Only Report’ for increasing the ‘Allowing Posting From’ and ‘Allowing Posting To’ date fields in ‘User Setup’ page.
- So that whenever the report is run, the dates present in those fields should be increased by day.
- As shown below, I’ve given proper Id and name with the required properties.
- Inside the dataset, I’ve used “User Setup” table.
- I’ve written my code inside the trigger OnAfterGetRecord( ).
- By using CalcDate function I’ve written the code for increasing the dates of “Allow Posting From” and “Allow Posting To” fields.
- And I’ve set modify trigger for ‘User Setup’
- And now the report is published!
report 50850 “Auto Date Update ReportV”
{
Caption = ‘Auto Date Update ReportV’;
ProcessingOnly = true;
UseRequestPage = false;
dataset
{
dataitem(“User Setup”; “User Setup”)
{
trigger OnAfterGetRecord()
begin
“User Setup”.”Allow Posting From” := CalcDate(‘<+1D’, “User Setup”.”Allow Posting From”);
“User Setup”.”Allow Posting To” := CalcDate(‘<+1D’, “User Setup”.”Allow Posting To”);
“User Setup”.Modify()
end;
}
}
}
- After running the report, in the Business central open the ‘Job Queue Entries’ page, click on new, give your report ID, automatically the name of my report will come.
- In the Recurrence section, select the days on which the report should run.
- Go to the Process section in the top and click on ‘Run Once’.
- Open User Setup page and check the dates, the dates will be increased by 1Day.
- The below image shows the previous date.
- After running the report, the below image shows the updated dates.
For more details kindly visit our linkedin page:
https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/mycompany/
By Vinyas. S.
How to create a List report in Business central
So far in the Report series blog, we have discussed about what is a report and the types of report. In this blog, let’s discuss about how to create a list report.
So, what is a List Report?
A list report displays the data in rows and columns from database.
Let’s now learn how to create a list report in VS code!
- Create a new file in VS code, once the file is created type “treport”, it’s a snippet to create a report.
- Specify the default layout as RDLC and specify the RDL layout in the report.
- Specify the data item and add columns, like mentioned in the below screenshot.
- Save the code, to create package go to “View” action click on “Command Palette” search for “AL:Package” and click on it, package will be created.
- Once the package is created, right click on the package click on “Open Externally”.
When you click on “Open Externally” RDLC layout will open in the report builder.
- When the layout opens, it will be blank. You have to design the layout.
- Go to Insert and select insert table to add fields to the table, expand the datasets in the left-hand side, drag and drop the field into the table.
8.Save the layout and close the report builder (or minimize).
9.Now need to run the report, go to VS code click on Run action click on Run without debugging.
10.Business Central page will open, search for your report, then click on Preview to view the result.
Result for above report will be like this.
For more details kindly visit our linkedin page:
https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/mycompany/
By Manasa. D.
PAGE in Business Central!
In Dynamics 365 Business Central, Pages are created to display and organize data. On pages, user interact with data. They can insert, modify or delete the data. Pages provide views of data.
A Page in AL Language contains:
- Page Properties
- Set of Controls
- Set of Actions
- Global Variables
- Page Triggers
The Structure of a Page is Tiered and categorized into three sections.
- The first block contains metadata for the overall page. It describes the page type and the source table its showing data from.
- The second block, the Layout, describes the visual parts on the page.
- The final section details the actions that are published on the page.
Creating a List Type of Page:
- We can use snippet (tpage) available in VS Code or we can define the page by ourselves. We have to choose snippet with page type List.
2.Next, we have to give Application Area, Usage Category and Name of our source table which we want to display/Use in our Page.
- Then inside Layout we define the content which we want to display on Page.
- In List Type of pages, we are required to define a repeater () control within the area (Content) control of a page. The list Pages are designed to use a single repeater () control, which has to be defined at the beginning of the content area. If we add another control like grid or group the page might not behave as expected.
- Then Inside the repeater() control we nest the field () control and add the fields which we want to include in the page, and the order of the field controls determines the order in which they appear on the page.
- In List type of pages we could add FactBoxes also as per our requirement, Typically, we use a FactBox to display information that is related to an item on the main content page.
- We could add actions also in the list page.
We can make various changes to customize the appearance of the list in a page and determine which data is displayed as per our Requirements.
It is advised, to design a page that includes controls in the content area other than a repeater, then we should try using a Worksheet page type instead.
For more details kindly visit our linkedin page:
https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/mycompany/
By Harshit T.
Introduction to Report in D365 Business Central!
Overview :
Reports in Dynamics 365 Business Central, is a document that presents information in an organized format. Reports are used to print or display information from database, for example-Sales Invoices. It provides information on various aspects of business and is easy and efficient and play a major role in streamlining the progress of business.
So how to develop a report?
Create a report object and design a dataset, Datasets decide which record from the Dynamic 365 Business Central database used to generate report output.
Types of Report Layouts:
- Word Layout
- Report Definition Language (RDL) Layout
- Excel Layout
Request Page:
Request page runs before the report starts to execute, which in turn allows the end-user to specify filters for a report.
Types of Report:
- Simple list report
- Grouping list report
- Document report
- Document with Header/Footer report
- Process only report
- Chart report
- Fixed format report or Pre-printed report
- Barcode and QR code report
Report Triggers:
OnInitreport: This trigger runs before the request page in addition it initialize the global variable.
OnPreReport: This trigger runs after the execution of request page before the report runs.
OnPostReport: This trigger runs after all the data item processed, in a simple way that this trigger runs at last.
DataItem Triggers:
OnPreDataItem: This trigger filters the value before the dataitem is processed.
OnAfterGetRecord: For each and every record this will trigger, until reaches to the final record this trigger will run multiple times.
OnPostDataItem: This trigger run after the last record in data item but before the OnPostReport.
SetData and GetData: To change the Header information according to the body part SetData and GetData is used.
Steps:
- Change the Code in Report Properties
- Create List
- Inside list insert new table
- Right click one of the textbox under visibility section show or hide add SetData code
Ex: Code.SetData(Cstr(Field!field_name.Value), 1)
Here 1 indicates first group
- In the Header Section inside the textbox write GetData by passing parameters under the Expression section.
Ex: Code.GetData(1,1)
Here first number indicates the filed value, and second number indicates the group value.
For more details kindly visit our Linkedin page:
https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/mycompany/
By Manasa D.
D365 Business Central How to work with Codeunit Object!
- A codeunit is a container for AL code that we can use in many application objects.
- We implement business logic in codeunits and call that particular codeunit from the object that needs to perform that specific logic or action.
Basically codeunit can be used in following way:
- First we create a codeunit snippet by using key word ‘tcodeunit’
- After that we will give the proper ID number and name
- In the procedure section we assign a proper name and write our logic in this section
For example:-
codeunit 50101 “Test Functions”
{
procedure Factorial()
var
IntValue, IntValue2, Fact : Integer;
begin
IntValue := 5;
IntValue2 := IntValue;
Fact := 1;
while
IntValue >= 1
do begin
Fact := Fact * IntValue;
IntValue -= 1;
end;
Message(‘IntValue = %2, My Factorial value is %1’, Fact, IntValue2);
end;
}
- The next step is to decide in which page we should see our desired result
- So we will create a ‘page extension’ for that page using snipper ‘tpageext’
- Inside the action section we give our action a name and call our code unit using a trigger
For example :-
pageextension 50101 CustomerListExt extends “Item List”
{
layout
{
// Add changes to page layout here
}
actions
{
addlast(Functions)
{
action(Factorial)
{
ApplicationArea = All;
Caption = ‘Factorial’;
trigger OnAction()
var
TestFunctionCodeunit: Codeunit “Test Functions”;
begin
// TestFunctionCodeunit.Run();
TestFunctionCodeunit.Factorial();
end;
}
}
After this, we should publish our program and check for the result
Advantages of CodeUnit :-
- CodeUnit is the best way for creating procedures
- We can simply call those codeunits wherever we wish in our program and this help in reusability .
For more information like this please follow our company LinkedIn page:
https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/
By Vinyas S.