Saturday 6 February 2021

Print and attach report to documents

 

You can now print document related reports and add them as attachments to a document itself. This is particularly helpful if your document goes through many versions that you want to keep a track of.

  1. Create a sales quote of 100 bicycles for a customer. There is Attachment factbox to navigate to any attached prints.

2. Release the quote. Navigate to Print/Send -> Attach as PDF. The sales quote report is printed by default and attached to the quote document

Drill down on the attachment to view it

When you convert this quote to order you see that it is also attached to the new order document. Now change the order qty or any other field in the document and save this version of the order confirmation to the order.

When you click Attach as PDF on the sales order you see a list of options because there are those many reports that can be printed and also attached to the order.

Search Pages in Business Central

 Menusuites are old age now with Business Central.

Pages have now come with a new property that makes them found on searching in your client.

The property is UsageCategory with values as below. The values replicate every behavior like the previous Menusuite.

NoneThe page or report is not included in a search.
ListsThe page or report is listed as Lists under the Pages and Tasks category.
TasksThe page or report is listed as Tasks under the Pages and Tasks category.
ReportsAndAnalysisThe page or report is listed as Reports and Analysis under the Reports and Analysis category.
DocumentsThe page or report is listed as Documents under the Reports and Analysis category.
HistoryThe page or report is listed as Archive under the Reports and Analysis category.
AdministrationThe page or report is listed as Administration under the Pages and Tasks category.

Reset credentials to extension

 I accidentally created my AL project using wrong credentials, which gave me a nightmare publishing it. I wanted to tell the AL project to please forget my previous login and ask me for a new one.


The trick is to clear cache of your previous credentials. Press Ctrl + Shift + P to open up the command pallet and search for clear credentials. Select the one.

Try to publish your app again and it asks for you to enter the credentials again.

Save your Symbols in a common folder using Package Cache Path

When you typically try to create a new AL Project, unless you already have done the changes mentioned in this post, you would need to download symbols for the base application for your AL Project. Doing this would then create a new symbol files attached to your project

And this can also be seen in your folder for AL Project

If there are many such sub projects you have created for say a larger project, you might not want to create and save these symbol files in each sub project folder. More so when they all need to refer to the same symbols collection.

One way of doing this is via a User setting. Open your VS Code and navigate to user settings.

GO TO Extensions -> AL Language Extensions and scroll down to the property Package Cache Path. This is where you need to set the path where symbols should be downloaded to and referred from every AL project you create.

The project was compiled successfully.

Remember this is a user setting and so is only specific only to your user. When deploying extensions, this needs to be taken care of. This can be done adding this folder to your project. Select File -> Add folder to your workspace. Select the symbols folder you created.

Friday 26 June 2020

What's your Password?

NAV offers its own way of storing Passwords. I am not so much into encryption (right now), but it does seem to not be quite the best way for password protection.  But let's know whats going on here

1. How can you enter/store a password in NAV? For eg; storing an FTP password.

Create a field called Password in a table (just for ease I use inventory setup)
Set the property ExtendedDataType = Masked (This masks the input as shown)


When you try to extract this data eg. as a message, the encryption fails and you see the password in full glory. 

2. So how is User Login information stored in NAV?

The great revelation is Codeunit 9801 - Identity Management

ValidateKeyStrength: When you enter a pwd in the user card, this function perform tests on it. By default NAV needs the pwd to be of 8 chars, at least 1 uppercase, at least 1 lower case, at least 1 number.

GetMaskedNavPassword:  Here's the fun part. If a pwd was set, NAV just displays '********'. Yes.  8 stars. They are not hiding anything. They aren't encrypted values. Just stars. 


Identity Management is good way to get into access and identity areas of NAV. 









Monday 12 November 2018

Import CSV File with Header using XMLPort

When we start to build an XMLPort, we specific the XMLport to be based on either a table or text variables. What happens when we import a file source having header in these two cases. Let’s cover these two cases in this post.
Data File: We are going to import data into Payment Terms table. Our csv file has header and the data as follows
       
(Scenario 1)




 (Scenario 2)

XMLPort using Text variables:


  1.   Source Type is the table of Payment Terms and we add 3 lined with source type text corresponding to the 3 fields.
  2. Create a Boolean variable as below
  3. Add the Boolean to the Request Page.
  4. Add the below code. When XMLPort reads the file, it evaluates/maps all the data in the file as text, since the source type is given to text. We need to further convert the text to respective field data types using evaluate function.
  5.   Run the XMLport as below and import the file.
  6. Payment Terms is updated as follows


XMLPort using Table and Fields:
  1. Source Type is the table of Payment Terms and we choose relevant fields that we shall import.
  2. Create a Boolean variable as above
  3. Add the Boolean in the Request Page as above. 
  4. Now is the main difference between importing into a source table directly vs. using text variables. When we import data into source tables directly, the header data i.e text in the file cannot be evaluated into non-text data type fields we have selected. Because XMLPort reads every line of CSV and tries to evaluate into respective fields. For this, we instruct NAV to skip the first line if our file has headers, like above. But we cannot assign it in the OnBeforeInsertRecord() because the evaluation (NOT Insertion) takes place before this trigger. So we place the code to skip the first-line import in OnAfterInitRecord() which is triggered before any evaluation into fields or assigning into variables takes place.
  5. Run the XMLPort choosing 'File contains Header' and select the file.
  6. The Payment Terms gets updated




Hope this helps!

Monday 29 October 2018

Using XML DOM Management to export data in XML

In this demonstration, we will be making use of the XML DOM Management codeunit and its capabilities to export the Payment Terms data in XML format.