Getting the source code of the .app extension in Microsoft Dynamics Business Central
Objective: This blog demonstrates how to get the source code of the extension app installed in Microsoft Dynamics Business Central. Pre-requisite: Docker Microsoft Dynamics 365 Business Central on Container Nav-Container Helper Module installed in Powershell Demonstration: 1. List the Docker Container: Command: docker ps 2. Entering the Container: Command: Enter-NavContainer <Container Name> 3. List all directories in Container: Command: dir / ls 4. As Extensions are stored in C:\Extensions getting into Extension directory Command: i. cd C:\Extensions ii. dir 5. Exit the Container: Command: exit 6. Copy the .app file inside the container to local path: Command: docker cp <Container Name>:C:\Extensions\<Filename><LocalDirectory> 7. Make a copy & rename the file with .rar as extension 8. Extract the .rar file and explore the ‘src ‘ folder to get the source code in .AL files Conclusion: Thus, in this way the source code is visible and can be used for reference.
Share Story :
Modifying the Primary keys of records in NAV
Introduction: This blog demonstrates how to modify the non-key fields with respect to the key fields. Pre-requisites: NAV 2017 Demonstration: Generally, when modifying the records, the syntax used is Record.FieldName := New_Value; Record.MODIFY(TRUE); In order to do modify the Key fields of the table, we need to know the order in which the keys are assigned. To modify the primary key, the syntax used is Record.RENAME(Key1,Key2,Key3); Where, Key1 corresponds to value that is supposed to be assigned to ‘No.’ field. Key2 corresponds to value that is supposed to be assigned to ‘LineNo.’ field. Key3 corresponds to value that is supposed to be assigned to ‘Leased to Driver No.’ field. Even when the single key field is to be changed, all the key fields should be present in their sequential order. If there is any mismatch in the number of keys, NAV throws the following runtime error. Note: Renaming operation is a costly operation. Creating a New record and Deleting the old record is faster as compared to Rename. In case where the performance is the requirement, the second method is preferred.
Share Story :
Workaround to Report.SAVEASPDF in NAV 2018
Objective: In NAV 2017 Emailing the PDF by running the report using Report.SAVEASPDF is now not allowed in NAV 2018. The reason is that temporary server file as not allowed to be saved for some security reasons. Thus this blog demonstrates the workaround solution for this issue. Pre-requisite: NAV 2018 Demonstration: 1. Concept: With respect to NAV 2018, Microsoft says that Emailing the attachments should be done using Streams. Thus, we’ve to convert the PDF generated by running the report into a stream and pass the stream as an attachment (https://community.dynamics.com/nav/f/34/t/270046). Before running the report, the data needs to be passed appropriately to the Report. Report.RUNMODAL method cannot be used as running report requires XML Parameters. For this, we make use of XMLParameters that are sent to the report through either a request page or as XML Text which contains a list of parameters to be passed and then the report is run. 2. Procedure: Step1: Generate the XMLParameters(Text) using the RUNREQUESTPAGE method and copy the results. REQUESTPAGE is used to set the filters prior to running the report. The filters selected are passed to the report in XML format. Value in XMLParameter: Here, Rec.Contract No. is the primary filter to be passed to the report. Step2: Create the Instream and Outstream variables and a temporary table having BLOB field. Create the OutStream variable for the BLOB field of the Temporary Table. Save the data of OutStream variable using Report.SaveAs method. Copy the data of the BLOB field to Instream Step 3: Pass the attachment as a Stream using Instream Note: Perform the Step 1 only if there is any filter to be applied to the report. Conclusion: This workaround is to be used where the Report.SAVEASPDF cannot be used because this method is not allowed in AL.
Share Story :
Saving the Data of NAV 2018 after upgrading the extension in Visual Studio Code
Introduction: In NAV 2018, after installing the extension the data of the newly created fields using extension is to be filled. But after upgrading the extension the data of the added field gets flushed out. Thus, this blog demonstrates how to configure to prevent the data from getting flushed. Pre-requisites: NAV 2018 CU2 along with its Installation DVD Zip Demonstration: Goto Visual Studio Code and uninstall the previous version AL Language Extension. Install the extension from AL Language from the path “C:\Users\<Username>\Downloads\CU 02 NAV 2018 NA\NAV.11.0.20348.NA.DVD\ModernDev\program files\Microsoft Dynamics NAV\110\Modern Development Environment/ALLanguage.VSIX” file. Select the .VSIX file. Reload the AL Language Extension. Adding the following lines to ‘launch.json’ file If the data is to be saved :- “schemaUpdateMode”: “Synchronize” If the data is to be flushed :- “schemaUpdateMode”: “Recreate” Conclusion: This feature wasn’t included NAV 2018 and the data used to get flushed everything the extension was upgraded. Thus, the data flushing issue was resolved in NAV 2018 CU2 version.
Share Story :
Creating a Control Add-in using Javascript and calling it in AL.
Introduction: In NAV 2017, control add-ins were called through .NET code which is imported as .ZIP files. With NAV 2018 .NET is not supported in extensions. Thus we’ve to perform the following steps to make a Control Add-in in Javascript. Pre-requisite: 1. NAV-2018 2. VS Code Procedure: Create a Startup script as start.js: Startup scripts are loaded whenever the NAV object containing the control add-in starts. Basically, the startup scripts are used for initialization. Create a Javascript file as demo.js : Contains most of the logic that the control add-in performs. Create a control add-in object in AL: Control Add-in objects are used by NAV to register the control add-in and events and procedures on which the control add-in works. Create a NAV object using AL: This object generally contains the control add-in integrated into the standard, created or customized NAV objects. This object acts as the starting point where events are performed. Output: Added Control Add-In: Invoking on INIT: Script Invoking on Event: Conclusion: Thus, we can create control add-in using Javascript and access in NAV .AL objects using extensions
Share Story :
Converting NAV C/AL Objects into AL using TXT2AL converter tool
Introduction: When migrating from NAV 2017 to NAV 2018 i.e moving from C/AL to AL the created objects need not be created again from scratch in AL. This blog demonstrates how we can create the AL objects from C/AL using Txt2Al in Command Prompt. Pre-requisite: NAV 2018. Backup of Objects in TEXT or FOB format. Steps: 1. Import objects in NAV 2018 from the created .TXT or .FOB files. In NAV Development Environment goto, Files > Import > Choose the .FOB or .TXT file > Replace all the objects 2. Export the objects in New Syntax to .TXT files. Create a directory to store the objects in .TXT format which will be exported as new syntax. Here, ‘source’ is the name of the directory used. Use ‘mkdir source ‘ Create a directory to store the .AL that will be created by TXT2AL Converter utility. Here ‘target’ is the name of the directory used. Use ‘mkdir target’ To export the objects in .TXT format in NewSyntax use the following command where Source Directory = ‘source’ Filename = ‘CU0-5.txt’ Database Name = ‘Demo Database NAV (11-0)’ SQL Server Instance = ‘.\NAVDEMO’ Type of Object = ‘codeunit’ ID = ‘50000..50005’ —-is the ID range Similarly, for Tables: Type of Object = ‘table’; ID=’50000..50005′;filename=’TAB0-5.txt’ Pages: Type of Object = ‘page’; ID=’50000..50005′;filename=’PAG0-5.txt’ Queries: Type of Object = ‘query’; ID=’50000..50005′;filename=’Query0-5.txt’ Reports: Type of Object = ‘report’; ID=’50000..50005′;filename=’REP0-5.txt’ Menusuite: Type of Object = ‘menusuite’; ID=’50000..50005′;filename=’MS.txt’ XMLPort: Type of Object = ‘xmlport’; ID=’50000..50008′;filename=’XMLPort.txt’ NOTE: TXT2AL requires objects exported in New Syntax 3. Generate the .AL object files using the TXT2AL converter. To generate the .AL file from the .TXT files from source folder, run the following command where Source Directory = ‘source’ Target Directory = ‘target’ –rename = Used to create new .AL file per new object and give it the appropriate name of the ID and name. Conclusion: Thus, in this way, we can convert the objects in C/AL to AL format. Although the conversion is not 100% perfect but, most of the redundant work can be avoided.
Share Story :
Creation of Reports using AL Extension in Microsoft Dynamcis NAV Development Preview
Introduction: This blog demonstrates the creation of Reports through extensions in Microsoft Dynamics NAV Development Preview Environment(Microsoft Dynamics 365 for Financials and Operation, Business Edition). Pre-requisite: Microsoft Dynamics NAV Development Preview Environment Visual Studio Code with AL Extensions Demonstration: 1. Creating a Report using AL extensions. report 50100 MyReport { UsageCategory = ReportsAndAnalysis; ApplicationArea = All; CaptionML = ENU = ‘MyCustomerList’; RDLCLayout = ‘ReportLayouts/MyReport.rdl’; // WordLayout=’ReportLayouts/MyReportWord.docx’; // DefaultLayout=Word; dataset { dataitem(DataItemName; Customer) { column(CustomerName; Name) { } column(CustomerNumber; “No.”) { } } } requestpage { layout { area(content) { group(GroupName) { field(HideDetails; HideDetails) { } } } } actions { area(processing) { action(ActionName) { } } } } var HideDetails: Boolean; } 2. Creating a Page Action to run the Report using AL extensions. pageextension 50100 MyExtension extends “Customer List” { layout{ } actions { // Add changes to page actions here addlast(“&Customer”) { action(ShowMyReport) { ApplicationArea = All; trigger OnAction(); begin clear(myReport); myReport.Run; end; } } } var MyReport : Report MyReport; } 3. Installing the extension and executing the Report, the results are blank as the Layout for the Report is not set. 4. To create the layout, search for ‘Report Layout Selection’. 5. Then select the report added through the extensions and Export the template. 6. Open the RDL Export file in SSRS or Visual Studio and add the relevant fields or tables. 7. In the Visual Studio Code add the following lines of code. RDLCLayout=<PATH of RDL File>; UsageCategory = ReportsAndAnalysis; ApplicationArea = All; 8. Viewing the Report Conclusion: Thus according to the NAV 2018, the report when created in C/SIDE automatically has an RDL file associated with it. But when creating reports through extensions separately the layout needs to be created.
Share Story :
Implementing extensions in NAV Development Preview using Docker
Introduction: This blog describes Container, Docker, and Benefits of using Containers. As containers was a new functionality in Microsoft Dynamics NAV Development Preview from September Update, this document also demonstrates creating containers and how to implement extensions using containers. Also, it includes saving the image into Azure Container Registry Service. Pre-requisites: Microsoft NAV Development Preview(December update) Visual Studio Code(VS Code) Description of Containers: 1. What is a Container? A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows based apps, containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure. 2. Why do we use container? When you are running an app on a computer, you stand the risk that it will conflict with everything else on the machine. If two apps are having the same name and utilizing the same folder structure on the hard drive, there is a conflict and if 2 apps are using different versions of the same DLL, there might be problems.With a container, you achieve a higher level of isolation. Each container has its own file system, its own registry, its own network layer with its own published ports, and of course its own memory space – kind of like a virtual machine, just without the fat guest operating system. 3. What is a Docker? Docker is the company driving the container movement and the only container platform provider to address every application across the hybrid cloud.Docker enables true independence between applications and infrastructure and developers and IT ops to unlock their potential and creates a model for better collaboration and innovation. 4. Implementing Docker: What is a Docker Image? An image is an inert, immutable, file that’s essentially a snapshot of a container. Images are created with the build command, and they’ll produce a container when started with run. Images are stored in a Docker registry such as registry.hub.docker.com. i. List of Docker Images ii. List of Containers PS C:\Users\cfadmin> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c45e57849c56 microsoft/dynamics-nav:devpreview-finus “powershell -Comma…” 14 hours ago Up 2 minute s (healthy) 80/tcp, 1433/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:7046-7049->7046-7049/tcp, 7045/tcp, 0.0.0.0:8080->8080/t cp navserver iii. Creating a new Container PS C:\demo> docker run -e ACCEPT_EULA=Y a9 Initializing… Starting Container Hostname is 0b04fbea782e PublicDnsName is 0b04fbea782e Using NavUserPassword Authentication Starting Local SQL Server Starting Internet Information Server Creating Self Signed Certificate Self Signed Certificate Thumbprint 52600A924814D5A8848D7990BC3F76F7FB6FAF66 Modifying NAV Service Tier Config File with Instance Specific Settings Starting NAV Service Tier Creating DotNetCore NAV Web Server Instance Enabling Financials User Experience Creating http download site Creating Windows user admin Enabling SA WARNING: This license is not compatible with this version of Dynamics NAV. Creating NAV user WARNING: This license is not compatible with this version of Dynamics NAV. WARNING: This license is not compatible with this version of Dynamics NAV. Container IP Address: 172.18.232.162 Container Hostname : 0b04fbea782e Container Dns Name : 0b04fbea782e Web Client : https://0b04fbea782e/NAV/WebClient/ NAV Admin Username : admin NAV Admin Password : Tyvo6712 Dev. Server : https://0b04fbea782e Dev. ServerInstance : NAV Files: http://0b04fbea782e:8080/al-0.12.15359.vsix http://0b04fbea782e:8080/certificate.cer Initialization took 105 seconds Ready for connections! Note: Instead of full Image ID starting few characters can be used as Identifiers. Image Name can also be instead of Image ID. Download the Certificate from the URL and installed in Enterprise Trust, Trusted Publisher. iv. Viewing the created Container PS C:\demo> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORT S NAMES 0b04fbea782e a9 “powershell -Comma…” 3 hours ago Up 3 hours (healthy) 80/t cp, 443/tcp, 1433/tcp, 7045-7049/tcp, 8080/tcp stupefied_stonebraker ca1980d041c6 microsoft/dynamics-nav:devpreview-finus “powershell -Comma…” 28 hours ago Up 6 hours (healthy) 80/t cp, 1433/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:7046-7049->7046-7049/tcp, 7045/tcp, 0.0.0.0:8080->8080/tcp navserver Newly Created Container with name as ‘stupefied_stonebraker’ and ID as ‘0b04fbea782e’ 5. In Visual Studio Code: i. Contents of Launch.json file ii.Contents of App.json file iii. Contents of Code unit which displays a Hello Message iv. Contents of Customer Card which Creates a field and an action that triggers the CodeUnit above v. Contents of Customer Table Extension that adds a field vi. in the Extension Management Pane vii. Action in Customer Action vii Displaying Hello Message viii. Added field in the Customer Card Page 6. Merging the Containers in Image and Managing with Azure Container Service i. Comitting the Container ‘stupefied_stonebraker’ to Image ‘microsoft/dynamics-nav:devpreview–finus’ PS C:\Users\vmadmin> docker stop stupefied_stonebraker stupefied_stonebraker PS C:\Users\vmadmin> docker commit stupefied_stonebraker microsoft/dynamics-nav:devpreview-finus sha256:eca05b64ed3619c688225685613e27fb4dbb6823aee46e24e96f3d813158440f ii. Tag the Image ’ microsoft/dynamics-nav:devpreview–finus’ as ‘navcontainerregister.azurecr.io/dynamics-nav:v1’ and push the committed image to Azure Container Service PS C:\Users\vmadmin> docker tag microsoft/dynamics-nav:devpreview-finus navcontainerregister.azurecr.io/dynamics-nav:v1 PS C:\Users\vmadmin> docker login –username NavcontainerRegister –password 6QiIyg9ICAa=aEg1jL2Wp8JumxvfPAEd navcontainerregister.azurecr.io Login Succeeded PS C:\Users\vmadmin> docker push navcontainerregister.azurecr.io/dynamics-nav:v1 The push refers to a repository [navcontainerregister.azurecr.io/dynamics-nav] 79bb52c8ab0d: Preparing 9c54b1a40ebc: Preparing 0d828dcd4895: Preparing b52bf723b284: Preparing 4beec416a215: Preparing 282537c6428c: Preparing b786ae432ac1: Preparing b07b88fd6145: Preparing 28c2b5be05f7: Preparing cc91b1f75f98: Preparing 7305c5891baa: Preparing bb5530559b18: Preparing 021428a01c82: Preparing 13b346524402: Preparing cda2d40c0d33: Preparing 64efa9cbaf9b: Preparing aa2b81bfb0aa: Preparing 505553846eae: Preparing 7a83b9538cb1: Preparing 20c2a3ed5225: Preparing 5437ac367abf: Preparing c856f8e0a2f7: Preparing f358be10862c: Preparing b07b88fd6145: Waiting 28c2b5be05f7: Waiting cc91b1f75f98: Waiting 7305c5891baa: Waiting bb5530559b18: Waiting 021428a01c82: Waiting 13b346524402: Waiting cda2d40c0d33: Waiting 64efa9cbaf9b: Waiting aa2b81bfb0aa: Waiting 505553846eae: Waiting 7a83b9538cb1: Waiting 20c2a3ed5225: Waiting 5437ac367abf: Waiting c856f8e0a2f7: Waiting f358be10862c: Waiting 282537c6428c: Waiting b786ae432ac1: Waiting b52bf723b284: Pushed 9c54b1a40ebc: Pushed 4beec416a215: Pushed b07b88fd6145: Pushed 282537c6428c: Pushed b786ae432ac1: Pushed cc91b1f75f98: Pushed 28c2b5be05f7: Pushed bb5530559b18: Pushed 021428a01c82: Pushed cda2d40c0d33: Pushed 13b346524402: Pushed aa2b81bfb0aa: Pushed 64efa9cbaf9b: Pushed 505553846eae: Pushed 20c2a3ed5225: Pushed 79bb52c8ab0d: Pushed c856f8e0a2f7: Skipped foreign layer f358be10862c: Skipped foreign layer 0d828dcd4895: Pushed 7305c5891baa: Pushed 7a83b9538cb1: Pushed 5437ac367abf: Pushed v1: digest: sha256:0aa9bfe03388e4fa20f83fcac99dafdf1933f58a2aed9d1c8bb2d05d162f062e size: 5343 iii. Azure Container Registry Repository: Pushed Image into Container Registry in Repositories Conclusion: These are the actions that can be performed on Container using Docker and how extensions are developed on Containers.
Share Story :
Setup UserName authentication in Dynamics NAV
Do you feel like the vast majority of your information lives in Excel spreadsheets? Joining deals with that, as well, Microsoft dynamics nav upgrade improves your operational productivity so you have all the more convenient information. This permits you to know things quicker like when to move stock from area to another, when to markdown items, and how to showcase in one district versus another. Coordination prompts snappier dynamics. The present clients request a great deal from vendors. Having the option to settle on basic business choices at the ideal time depends on having perceivability into your tasks. Mix is regularly the way in to that kind of perceivability. It gives you a focal area to oversee and see all your information. Introduction: In this blog, we’ll see the ‘UserName’ authentication in Dynamics NAV. It is used when we want to use the existing Windows User and has a password associated with it. This method is preferred when two or more users use the same machine and require a simple password security so that only they can access their account. Prerequisite: Microsoft Dynamics NAV Procedure: Create a User in Windows Client by going to Administration > IT Administration > General or by typing Users in Search. Create a NAV Server Instance from Administration with Credential Type as ‘UserName’. Change the ClientUserSettings ‘C:\Users\<Username>\AppData\Roaming\Microsoft\Microsoft Dynamics NAV\100\ClientUserSettings ‘Give the Server, ClientServicesPort, Server Instance & ClientServicesCredentialType. Open the Windows Client and enter the credentials. Windows Client HomePage: Conclusion: Thus, this method is preferred when two or more users use the same machine and require a simple password security so that only they can access their account.
Share Story :
Ways to Import Export Data from Microsoft Dynamics NAV to Excel
Introduction: In a scenario where a company uses Excel to keep the data and wants to move its ERP to Dynamics NAV. A lot of data needs to be added in NAV in order to get a full system working. Thus, copying each entry could be a time-consuming task. Microsoft Dynamics NAV is enabled with the feature to Import and Export Data to and from Excel. Procedure: Ways to Import Export Data from Microsoft Dynamics NAV to Excel There are two ways to Import Export Data to and from NAV Using XMLPORT(Server Side) Using Configuration Packages(Client Side) XMLPORT Method Steps: 1. Create a new XMLPORT in NAV Server Object Designer Window 2. Adding Entries in the XML Port NodeName: Root > Node Type: Element > Source Type: Text > Data Source: <Root>(By Default) NodeName: Table Name(Anyname is fine) > NodeType: Element > SourceType: Table > Data Source: Table(Select the Table click on the Rollup Button) NodeName:Field Name > NodeType: Element > SourceType: Field > Data Source: Field(Select from the Rollup) 3. Indent the Entries as Root(Indent: 0) > Table(Indent: 1) > Fields(Indent :2) 4. Changing the properties of the XMLPORT Delimiter: <‘’> Separator: <TAB> 5. Change the Properties of the Table Format: Variable Text AutoUpdate: Yes AutoReplace: No 6. Save the XMLPORT and RUN For the first time Choose the Direction as ‘Export’ > Save > Filename.xls 7. Open the file, make change the entries and close the file 8. Run the XMLPORT and choose direction as ‘Import’ and select the file Verify whether the import is successful by checking the entries in the table. IMPORT EXPORT using Configuration Packages 1. >Open the Microsoft Dynamics NAV (Client Application) and search Configuration Packages. 2. Create a New Configuration Packages > Enter the following values in required fields as Code: 123(Appropriate Number) and Package Name: Excel Import(Appropriate Name) > Select the Table ID:50001(Using Drop Down) and Table Details will be updated. 3. Under the ‘Tables’ ribbon click on Excel > Export to Excel > Save as appropriate file 4. Open the Excel File and change the entries 5. From the ‘Tables’ ribbon, select Import from Excel and Select the file 6. By this time the data is not written to the table just imported. Thus have to apply the data. After applying, it gives the data inserted or modified or errors if any. Conclusion: The fields are mapped first, thus all the fields to be Imported and Exported are to be known first. Only one excel file per table can be used. The file extension needs to be .xls and not .xlsx as it gives an encoding error while opening the file. Importing or Exporting computed fields cannot be done by this method.