Dynamics NAV

Wednesday, 14 January 2015

How to send Documents as Email in NAV2015

 We have an option for sending attachments as email is available from Microsoft Dynamics NAV2015. 
We can see in sales invoices, sales credit memos, sales orders, sales quotes, reminders, and finance charge memos, as well as some posted documents. 

The option is available in the ribbon and called Email or Post and email depending on the context. 
It displays a dialog that lets you attach the document together with a short message and send this as email directly from Microsoft Dynamics NAV. 

In Microsoft Dynamics NAV Windows client you can decide to modify the email more in your default mail program. 
The default email sender address is based on the settings in the SMTP Mail Setup window. 
If SMTP is not configured or Outlook is not available, the .pdf file will open instead.

How to Stop Negative Inventory in NAV2013 R2

In earlier versions we have to customize NAV to achieve this but NAV2013R2 brings this feature as standard.


We can set up that outbound posting that brings inventory below zero is blocked. 
This can be set up per item or for all items. 

This setup is in the Inventory Setup, we can put a check mark in Prevent Negative Inventory field
 which specifies if you can post transactions that will bring inventory levels below zero.

The selection that you make in this field indicates the value in the Prevent Negative Inventory 
field on individual item cards. The values will either be Default (Yes) or Default (No)
which you can change.

I know have setup this for all Items i.e., in Inventory Setup and when I try to post an Item which has
 in sufficient Inventory then I got below error.

Microsoft Dynamics NAV
---------------------------
You have insufficient quantity of Item 1000 on inventory.
---------------------------
OK
---------------------------




One or more filters are not valid and will be ignored Message in NAVISION RTC

Today I tried to run (Preview) a Report with Date Filter and I got below confirmation message


Microsoft Dynamics NAV
---------------------------
One or more filters are not valid and will be ignored. Do you want to continue?
---------------------------
No   Yes
---------------------------




























Then I found that this is because of Wrong date format entered in Birth Date filter.
Date format in My system is set to DDMMYY and I entered as MMDDYY.

But this behavior is different in Classic Client (NAV2009R2).

I tried to enter same MMDDYY format in classic client Birth Date filed.

But It gives an error message as shown below
---------------------------
Microsoft Dynamics NAV Classic
---------------------------
'013150' is not a valid date.
---------------------------
OK 
---------------------------



How to Update/Modify Data in All Companies in the current database

We have Table 2000000006 – Company,which contains the list of companies exists in the database.
And also we have CHANGECOMPANY Function

Redirects references to table data from one company to another.

[Ok :=] Record.CHANGECOMPANY([CompanyName])
We can create a ProcessingOnly report to update the data in all companies using above table and function.
Ex: If I have to Update "Allow Posting From" and "Allow Posting To" field of General Ledger Setup table in all companies then:
1. Create a Processing Only report with Company as dataitem
2. write below code in Company - OnAfterGetRecord() trigger
   
GLSetup.CHANGECOMPANY(Name);

GLSetup.MODIFYALL("Allow Posting From",010213D);
GLSetup.MODIFYALL("Allow Posting To",280213D);

//You can use variables in Request Form for From Date and To Date




Here GLSetup is global variable of record type variable with General Ledger Setup table.

How to Disable Personalization in NAV2013 RTC

In general to Customize/Personalize NAV2013 RTC, 

"Choose Column" and "Customize This Page" as shown below 





But we can stop disable these Custimizations/Personalizations using a setup in NAV2013 RTC

Go to Profiles page as below
CRONUS /Departments/Administration/Application Setup/RoleTailored Client/Profiles

Select Profile for which you want to disable personalization
Click on Edit
Set TRUE in "Disable Personalization Field".

Close RTC and Reopen

Now the above options are not available you have a look in the below screenshot for your reference.




Error: 5133 SQL Server while attaching the Database

When we  attaching database to the server we may get below error -


Microsoft SQL Server Management Studio
------------------------------
Attach database failed for Server 'XXX-XX--XX'.  (Microsoft.SqlServer.Smo)


For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.2500.0+((KJ_PCU_Main).110617-0038+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Directory lookup for the file "G:\SQLLOG\NAV_D_CQPA_370B_Log.ldf" failed with the operating system error 3(The system cannot find the path specified.). (Microsoft SQL Server, Error: 5133)
------------------------------













We can fix this error as below -

some time system will tale the Log file(.ldf) randomly which does not exist in the path. so
Check for the file path during attach. Delete the selected file then try to  attach the database again.

Now System creates the log files automatically.

How to Deployment Report Layouts in a Multitenant in NAV2015

In a multitenant Microsoft Dynamics NAV deployment, the built-in report layouts are stored in the application database because they are part of the report objects. Therefore, built-in report layouts are available to all tenants.  You cannot modify a built-in report layout from the Microsoft Dynamics NAV client but you use them as a starting point for building your own custom report layouts. Custom report layouts are stored in the business data database; therefore they are specific to the tenant. This enables you to create separate report layouts for each tenant.    



      A report can only have one built-in RDLC report layout and one built-in Word report layout. By default, the built-in RDLC report layout is used when the report is run in the Microsoft Dynamics NAV client unless there is only a built-in Word report layout, in which case, the built-in Word report layout is used.


                 






users can also create custom report layouts that are based on the built-in report layouts. This enables users to have several different layouts for the same report which they can switch among. Custom report layouts are managed from page 9650 Report Layouts in the Microsoft Dynamics NAV client. Unlike built-in report layouts, which are part of the report object, custom report layouts are stored in table 9650 Report Layouts of the database.
Custom layouts are report layouts that you design to change the appearance of a report. You typically create a custom layout based on a built-in layout, but you can create them from scratch or from a copy of an existing custom layout. Custom layouts enable you to have multiple layouts for the same report, which you switch among as needed. For example, you can have different layouts for each Microsoft Dynamics NAV company, or you can have different layouts for the same company for specific occasions or events, like a special campaign or holiday season.
You can create custom Layouts as shown below

              

Once we select the Boolean Insert Word Layout,Insert RDLC Layout,it will create the layouts.
As shown below



Now change the layout that is used on a report as shown below

1.      In the Search box, enter Report Layout Selection, and then choose the related link.
The Report Layout Selection window lists all the reports that are available for the company that is specified in the Company field at the top of the window.
The Selected Layout field specifies the layout that is currently used on the report.
2.      Set the Company field at the top of the window to the company that includes the report.
3.      To change the layout that is used by a report, in the row for the report in the list, set the Selected Layout field to required options among RDLC (built-in), Word (built-in) and Custom  
       




Now custom layout will run whenever the report executes in the test company.

How to add FactBoxes using Query in Dynamics NAV 2013 R2

Introduction

In this demonstration we will explore how to utilize query objects to provide visual statistical data in FactBoxes. For this purpose we will be using Dynamics NAV 2013 R2 version.
The FactBox control in Dynamics NAV is a non-editable right-side pane window which is aimed at providing a quick overview of some statistics for the selected entity (customer, item, invoice line, etc.). The idea is to use the pre-generated query to fill in the FactBox data and display it on a page. To achieve this, we will be going through the following steps:
  • Design the query
  • Create the FactBox
  • Add the FactBox to the page

Design the Query

In Dynamics NAV 2013 R2 Development Environment, open the Object Designer and select the Query object type. Click New to create the new query:
In the Query Designer, fill in the following query data structure:
The field GroupBy is filled in automatically. We added the Salesperson/Purchaser table as the top-level data item. This is the table we are going to use to get the names of our salespeople. We have added one column called Name to this data item.

Next, we have added the Sales Invoice Header data item indented below the Salesperson/Purchaser table. We did not add fields from the Sales Invoice Header table itself, but we changed the Method Type field to Totals and Method to Count. This tells Dynamics NAV to count the total records.

To connect the two tables and calculate the number of invoices per salesperson, select the Sales Invoice Header data item and click SHIFT+F4 to open its properties. Modify the properties as follows:
Click File, Save As and save the query as Salesperson Activity with a sample ID number. The query is generated as follows:

Create the FactBox

In this step we will create the FactBox where we will incorporate the data passed from the query designed previously. In the Object Designer, select Page object type and click New to create the new page. Save the page as Salesperson Activity FactBox with a sample ID. Click View, C/AL Gblobals and add the following variable:
Enter the following page structure:
Select the first empty row in the page designer and click SHIFT+F4 to open the page properties. Change the following properties as shown:
The source table for the page will already have the name of the salesperson to be displayed. What we need to do next is fill in the total quantity of invoices for this salesperson. We will be using the variable InvoiceCount we added above to store the values from the query we created earlier.
Click View, C/AL Globals, and on the Functions tab, add the new function FillTempTable. Close the Globals window and press F9 to open the code designer. Scroll down to the FillTempTable function and while inside the function code, click View, C/AL Locals and add our query as a local variable:
Close the C/AL Locals window and add the following code to the function:
What we do here essentially is:
  • Reset the count variable for each salesperson;
  • Set the query data according to the values in the Salesperson/Purchaser table
  • Open and read the query to calculate the invoices for each salesperson
  • Close the query
Next, we need to place this function on the appropriate page trigger. Scroll up to the following triggers and add the code as shown:
In this way, we tell the system to run and process the query after retrieving the record from the database.
Close and save the page. When we run this FactBox page, we see the following:

Add the FactBox to the Page

The final step is to incorporate the FactBox page into the Salesperson/Purchaser Card page. In the Object Designer, find page 5116 Salesperson/Purchaser Card and click Design. Navigate to the FactBoxArea container and add our FactBox as shown:
Click SHIFT+F4 to open the properties for this page part and change them as follows:
The SubPageLink property actually links our FactBox data to what is displayed on the Salesperson/Purchaser Card at the moment. We are lining the data by the Code field. Save and close the page. When run, we can see the following:

Conclusion

This simple example shows how powerful the combination of Query and FactBox can be. The aim of a query in these cases is to join several tables’ data and display it in an informative view via FactBox control.
Let us know in the comments if you were able to successfully use Query and FactBox together. We’d love to hear about the solutions you come up with!