Dynamics 365 Business Central: How to print image with hyperlink for the selected report
In this blog, let us discuss about ‘how to add image with hyperlink to the report in Business central’.
Consider, if I need to advertise my additional item/product in the report, meaning, when someone buys my product with the product report, I need to advertise my additional product, which is related to the main product, such that, when any user clicks on the product URL, they should be able to browse and explore more about the product and buy in case they are interested in the additional product as well.
Now let’s see how it is done!
- Create a table to add the images.
Here I have created a table called Advertisement-Master and added required fields like “No.”, “Item Description”, “Item URL”, and “Item Image”.
For “Item Image”, the datatype has to be “MediaSet” and one Boolean field to specify in which report product advertisement has to be printed.
You can specify the reports to print Image by enabling and disabling these fields.
2.Create a Page for the table
Add all the above created fields to the page. Below screenshot is my ‘list page’ and I have added all fields to the page.
Item image” can be inserted through “FactBox”, to achieve that, lets create a “CardPart page” to insert the Item Image.
Below screenshot is for the reference to insert “Item Image” through “FactBox”.
Next step is to add “field Image” and added Two actions to Insert and Delete “Item Image”.
In the actions I am calling “ImportFromDevice” procedure and “DeleteItemImage” procedure.
The procedures which I am calling is described below.
3. Add Hyperlink property to the report
To add Hyperlink in the report layout, first hyperlink has to be enabled to achieve this. In the report use the property “EnableHyperlinks” and set it “True”.
Ex: EnableHyperlinks = true;
Below is the example to display “Item Image” in the report.
Inside the “OnAfterGetRecord” trigger, use the below sample code to display image in the report.
4.RDL layout
Open the RDL file and add the “Item Image” column, as shown below.
When the Click action is performed on that image, it will take to the specified URL. To achieve this:
- Go to “Image properties”, by right clicking on the “Item Image column”.
- In the Action section enable ‘Go To URL’ and specify the ‘URL’ under ‘Select URL:’, as shown below.
Save the changes and run the report.
Here is the result:
This is result of the “Item Image page”, here I have enabled “Boolean” fields, to print the image and right side is the “FactBox” where you can insert or delete the image.
So, this is the output of the report printing image, when the user clicks on the image it will take them to the specified URL.
For more details kindly visit our LinkedIn page:
https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/mycompany/
or you can write us on contact@allgrowtech.com
By Manasa. D.
Dynamics 365 Business Central-How to modify the posted transaction.
Description: As we all know that the Business Central do not allow us to modify the posted transaction, means once the transaction has been posted you cannot edit it.
- Considering ‘Item Ledger Entries’ as posted transaction table which is non-editable and in case you need to update any record in there then what we can do.
- Creation of the records happen when we post a Sales Order, Purchase Order or Item Journal Lines.
It is a record created after we post these documents.
- By default, Business Central won’t provide us the permission to alter these posted records.
- But what if anyone wants to modify these records?
- let’s see how it can be done through this blog
Creating a new Table and Page
- First, I created a new table and page with the name “Lot No Info” which contains all the fields I wanted to edit in ILE
- I also added ‘Entry No,’ for this new table and page and made this as a “PK“
- And I wrote a procedure and called that procedure on “OnOpenPage()” trigger of our new page, so whenever this page opens, it should copy all the field details from the ILE to this new page.
- In the above-mentioned procedure, I validated all the fields which I wanted to modify in the ILE.
- So, once I open the page, all the records from the ILE will be copied to our new page. But I wanted all the records of Entry Type – Purchase and Positive Adjustment. That’s why I’ve applied the filter in my code.
- Since I’ve validated the ‘Entry No.’ field, the ‘Entry No.’ field from ILE will be copied to our new page along with all other fields.
- So once all the records are available in our new page, we can modify the field values.
- So, the first half work is done. The next part would be updating the changes what we have made in our new page to the ILE.
- But simply we cannot modify the base table. For that, first we have to provide permission to the base table ‘Item Ledger Entry’ to Read, Modify, Insert, Delete
- After assigning the permission, I’ve created a procedure to copy the records from the new page ‘Lot No Info’ to the ‘Item Ledger Entries’ which is based on the PK ‘Entry No.’
- And this procedure is called under an action in the newly created page ‘Lot No Info’.
- So, when the new page is opened, all the records from the ILE will be copied to our new page. And we modify the some of the records and click on that action.
- After clicking on the action, if we go and check the ILE, we can see the modified records.
- But remember, all the changes are done based on the PK ‘Entry No.’
For more details kindly visit our linkedin page:
https://www.linkedin.com/company/allgrow-technologies-pvt-ltd/mycompany/
or you can write us on contact@allgrowtech.com
By Vinyas. S.
Dynamics 365 Business Central- check if an Extension is Installed
In the Business Central, some time we would like to perform certain operation depended upon another extension installed on the same tenant and the only idea comes to our mind is via app dependency, but there is something else which can be useful if you are only looking to access the data from the other extension.
In today’s Blog we are going to talk about how to check another extension and its data deployed on the same tenant.
First Approach
Using the Microsoft library called Microsoft.Dynamics.Nav.Apps.Management
We can use Get-NAVAPPinfo to get the basic information about the Business central APP installed on the tenant.
[Ok: =] NavApp.GetModuleInfo(AppId: Guid, var Info: ModuleInfo)
It will return false if the supplied AppId is not installed, otherwise, you’ll get all info about the installed app in the Info variable.
So, we can create a procedure like in image below.
We need to pass AppId then NavApp.GetModuleInfo(AppId, Info) will return true if extension(app) is installed else this will return false.
Second Approach:
For this second method we are required to know the Table Id of that extension.
As we know, we can use RecordRef to open any table in Database. RecordRef.Open(TableNum) Unfortunately RecordRef.Open() does not return a Boolean value, so we can’t just test RecordRef.open() to know if that table is present or not.
We can use a [Try Function], [Try Function] will return a ‘false’ on an error, rather than throwing the error and stopping.
Then we can use this function to make the required decision.
Hope you find this information useful. for more information please do visit our website allgrowtech.com and there you can access list of NAV/BC related topics.
To know more about the topic, you can write us on contact@allgrowtech.com
By Harshit. T.
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.