Business Central

Wednesday, 3 August 2016

Concept of Job Queues (Lets go through the path of NAS Service in Dynamics NAV)

Job Queue enables to request, control the processing of report and execution of codeunit.
In job queue entries window, we enter the request for execution of report/codeunit. 

Once the job queue execution of codeunit/report is done it will update its status of success/failure in Job queue log entries.


In NAV 2015, 2016 Job Queue can be activated in 2 ways.

1. Manually with credentials of Server instance.  
2. through NAS server with credentials of user.


Job queue uses NAS to run objects automatically. 

So, before understanding job queue we need to know what is NAS, why we need NAS.

In this blog I will be discussing particulary the concept of NAS and how to configure it in various versions of NAV.

What is NAS ?
NAS service is a middle-tier server component that executes the business logic without user interaction. 
In NAV it supports application like microsoft office outlook integration and NAV job queue.  

Why we need NAS?
  • Efficiency and convenience - Create a separate instance for each NAS Service so that it doesn't interrupt other services. 
  • Performance - Configuring NAS to separate instance makes better use of server computer. It allows us to run more application with less degradation.
  • Efficient error tracking - If the NAS service terminates then it can be handled like any other windows service by configuring the recovery tab on server configuration tool in control panel to manage service. 

Configuring NAS server in NAV 2009, 2013 is different from configuring in NAV 2013 R2, 2015, 2016.

Earlier all the services were separate but now we can see the services like Client, SOAP. ODATA, NAS, Management services all in one single administration tool. This makes a way by running one instance it will make run many services.


So as versions of NAV got changed configuring NAS service also became easy.

1.     Configuring NAS in NAV 2009 and 2013.

To do this you should have Application server manager for microsoft dynamics nav. 

Go to start, search for Application server manager for microsoft dynamics nav.
If you don't find any, 

Then go to your DVD installer of NAV run the setup file.
Select Add or remove components as shown below.


Select Application server and choose run from my computer in the drop down.

Once done, click next and wait until installation is successful.
Now you have Application server installed in your machine.
Go to your local services by searching in start button for services or by just clicking in Run prompt for services.msc. You will see the service installed as shown below.
Logon with your domain account instead of Network service.
Right click on below mentioned server, properties – Logon - > enter your system login id and password.



Now in your start menu, open Application server manager for Microsoft Dynamics NAV.
Right click on application server – select new application server.

Provide the host name – local host
Service name – BHEESHMA-SQL (the name which is displayed in the above marked service.

A new node will be created. Just click on this node and enter details of the server you are using, the database name and company.
To setup job queue the parameter should be JOBQUEUE as described below.


Click on Start the service.
You can check for the active sessions that are running in your machine by running the system table active sessions.
In your NAV development environment go to Database information and select current sessions.
There you must be able to see the new sessions configured as shown in below fig.



Once you verify that NAS service is running start configuring a job queue.


How Job queue works in NAV 2015. 

I explained how to do setup in NAv 2009. In NAV 2015 its pretty easy jus go to your server instance and go to NAS services and give the codeunit and starting method you need to run.

1. To schedule a job queue in NAV 2015 same applies in NAV 2009 R2. In your RTC client, go to Job queue entries click on new.
Choose the report or the codeunit you need to run.


I've given No. of minutes between run as 1 which means for every one minute the report will be run automatically without user interface between the start and end time.

In the above example I've took General Journal - Test report. I have filled the data as shown in above fig. 

Now click on Set status to ready so that now it is ready for job queue. 

2. To run a job queue, go to Job queue card and in NAS Settings, specify  NAS computer  your are using and NAS instance. 
once its done click on start job queue. 

you will get the following warning message.

Start the NAS service.
Once you are done with above steps. The NAS server will internally run the codeunit or the report you mentioned automatically from the specified time.

If it has to be repeated everyday at some specified time. Then mention the date and time it should run in Job Queue Entries page and go to Recurrence fast tab and then select the day and time the codeunit/report should run automatically.




Thursday, 9 June 2016

An Overview of Journal Template, Journal Batch and Journal Line

Journal Template :
They provide Journal structure and default information for journal batches.

Journal Templates are located in Journal Template page.


Definiton of Journal Template contains a series of attributes such as,


1. Name

2. Description
3. Type
4. Recurring
5. No. Series

Journal Template has relevant attributes that define nature and behavior of journal templates,


Journal Template Table field: Defines the Description of Journal


Test Report ID: Simulate the posting process

ex: General Journal as the associated test report named General Journal - Test

Posting Report ID: This report is printed when the user selects post and print.


Page ID: Some journal may require UI objects.

Ex. General Journals which have a special page for bank and cash.

Source code: Here you can enter trail code for all posting documents which are done through this  journal.


RecurringWhenever you post lines from a recurring journal, new lines are automatically created with a posting date defined in the recurring date formula.


Each journal template defines a default value of those attributes. The values that are defined in a template will be inherited by the journal batches which will be further inherited by journal Line.


Journal Batch: Journal batches usually serve to lines created by 2 different users called group journal lines.


They're created with the help of journal templates.



A journal batch is typically used to make a distinction between collections of logically grouped journal lines. A typical design is to have a journal batch for each user who enters lines. The batches are used during the posting process, in order to post one or multiple lines at once.

As shown in fig. The batch we have used is CASH for posting process to post that particulat line.



Journal Lines: Journal line will temporarily hold the transaction data until it is posted.

Until posting, Journal lines will be in draft state, means you can do correction/deletion o data.
Once the entry is posted line entries in journal are converted to Ledger Entries.





Journal lines contain the actual business data (posting dates, account numbers, amounts) that will be posted as ledger entries.

During posting, only the information from the journal lines is needed. However, the information has been created with the help of the journal templates and grouped together using the journal batches.
Posting creates ledger entries from the temporary content that is stored in the journal lines. Ledger entries are not created directly. Instead, they are posted from journal lines.
reference from community of dynamics.


In this, journal templates and batch is used if we need to create and post one or more entries. So, they're implemented in multiple areas of application like sales, purchases, cash receipts, payments, fixed assets.


Aggregation


There is a 1:n aggregation relationship between journal templates and journal batches, as well as between journal batches and journal lines. Deleting a template will cascade deletion of the related batches and lines. Deleting a batch will cascade into deletion of related lines.

Recurring Journals

A recurring journal is used to post transactions that repeat periodically. In a recurring journal, the user enters only the variable data, such as posting date, amounts, and accounts to be used for posting.
After posting a recurring journal, new journal lines are created containing the posting date for the next recurring period. The posting date recurrence pattern is previously defined in the Recurring Frequency field (for example, monthly recurrences(salary of an employee) are defined with the date formula 1M).
A boolean field named Recurring is placed on both the journal templates and journal batches, giving the possibility of defining the type of the journal to be used.

Standard Guidelines respected to navigation:



To keep a consistent user interface experience, it is recommended that the the following guidelines are taken respected concerning navigation:
  • Journal template to journal batches:
  • On the Journal Templates page, create an action called "Batches" and place it in the Navigate tab of the ribbon. Link the action to the batches list page.


fig shows batch action created and as been linked to batches list page. 

  • Journal batch to journal lines:
  • On the Batch page, create an action called "Edit Journal" in the Home ribbon tab.Link the action to the journal lines list page.




The action as been linked to journal lines through code.

In EditJournal - OnAction() trigger

GenJnlManagement.TemplateSelectionFromBatch(Rec);

Go to definiton of TemplateSelectionFromBatch(Rec) function and there you can see General journal lines as been called through code as shown below.



To keep a consistent user interface experience, it is recommended that the the following guidelines are taken respected concerning posting:
  • Posting multiple batches
  • On the Journal Batches page, posting actions (Post, Post and Print) are available. When invoked, the batch posting will iterate through all related journal lines and trigger the posting routine for all of the lines.



General Journals

The General Journal Templates page (101) uses the Gen. Journal Template table (80).
Various template types are defined: General,Sales,Purchases,Cash Receipts,Payments,Assets,Intercompany,Jobs. Based on the journal type, two other attributes are automatically set on the template lines as follows:
  • Page ID: Defines which journal page relates to the current journal template
  • Source Code: Filled with the default codes that are defined in Source Code Setup table (242).
The General Journals Batches page (251) is linked to the Gen. Journal Batch source table (232), which has a multiple-to-1 relationship with Gen. Journal Template table, based on the Journal Template Name field.
Some of the fields in the Gen. Journal Batch table are not editable. Instead, their value is automatically calculated from the parent Gen. Journal Template table. For example, the Recurring field (22) is a FlowField with the following calculation formula:
Lookup("Gen. Journal Template".Recurring WHERE (Name=FIELD(Journal Template Name)))
Similarly, the Template Type field is a FlowField that gets its value from the parent table:
Lookup("Gen. Journal Template".Type WHERE (Name=FIELD(Journal Template Name)))

Setting up a New Batch

When the user creates a new batch, the following field values are transferred from the Gen. Journal Template table to the Gen. Journal Batch table:
"Bal. Account Type" := GenJnlTemplate."Bal. Account Type";
"Bal. Account No." := GenJnlTemplate."Bal. Account No.";
"No. Series" := GenJnlTemplate."No. Series";
"Posting No. Series" := GenJnlTemplate."Posting No. Series";
"Reason Code" := GenJnlTemplate."Reason Code";
"Copy VAT Setup to Jnl. Lines" := GenJnlTemplate."Copy VAT Setup to Jnl. Lines";
"Allow VAT Difference" := GenJnlTemplate."Allow VAT Difference";

Cascade record deletion

When a record from the Gen. Journal Template table is deleted, the corresponding Gen. Journal Batch and Gen. Journal Line records are also deleted.

Cascade updates

When the reason code or the posting number series change in the current batch, all linked Gen. Journal Line records are updated (see ModifyLines function on the Gen. Journal Batch table).
The Gen. Journal Line table (814) stores a relation with the Journal Batch Name field (51) in the Gen. Journal Batch table. The Gen. Journal Line table also inherits the table relation with the Journal Template Name field (1) in the Gen. Journal Template table.

NAV Usages

Implementations of this pattern in NAV include:
  • General Journal 
  • Item Journal
  • Resource Journal
  • Job Journal

Reference from community.dynamics.com

Sunday, 5 June 2016

metadata in Dynamics NAV

A set of data that describes and gives information about other data.

In NAV,
if the object is compiled, a metadata will be specified.

We need metadata because, its used on NAV Server to allow running and debugging the object.


Ex:
If you have a table 18 customer, a record will be created for that when you compile it,



  • If the record(metadata) is missing for an object, then you cannot run object on NAV server.
  • when you compile an object in development environment. Record(metadata) is automatically generated.

Metadata field, Object metadata table.

Specifies XML metadata for the object. This allows the object to be run on Dynamics NAV Server.



  • Metadata is stored in Table 2000000071 object metadata for all navision objects whether it is visible or hidden. 
  • usually system table "Object Metadata" is created when we restore the database after creating the keys for various tables while processing the objects.
  • For visible objects these metadata's are automatically created when we compile the particular object. 

Friday, 22 April 2016

How to reduce Impact on Server and Network traffic.

To reduce impact on server :

1. COMMIT Function : Usually they're automatically handled by database. So avoid using it as much as possible.

2. LOCKTABLE Function : During inserting, modifying, renaming and deleting a data in a table. The SQL Server will automatically locks the table. So, avoid using it.

Example :

Consider a Customer table-

Developer A will check the cost between 10,000 to 50,000. If necessary he 'll modify some value.

If Developer B is also working on same database and same Customer table, modifying the value by Developer B will also affect the changes of Developer A. So, Developer A will lock the table while working or retrieving any value from table.

But, since SQL Server will lock the table automatically when you try to modify the data. Hence, avoid using LOCKTABLE function.



3. Don't examine(or verify) return values of insert, modify, delete function, If it is examined server must be notified.

4. Avoid Roundtrips to the servers.
Round trips - A round trip consists of a request sent to the server for data or an action (whenever a call to insert/modify/delete trigger for an action it takes time and resources which impacts on server.

4. Use CALCSUMS and CALCFIELDS function - Use it whenever you get a chance, to avoid examining records to total values.

5. Use SETAUTOCALCFIELDS function - Whenever you need to obtain value of flowfield for every single row in loop.


To reduce Network Traffic :

1. Apply keys and filters, and use MODIFYALL and DELETEALL functions instead of using modify and delete for each record.

2. To perform calculation on server fields that have single function call, use CALCSUMS and CALCFIELDS (both will take multiple parameters)


Extended stored procedure error (xp_ndo.dll and xp_ndo_x64.dll) in NAV 2009

Ever you faced a problem when you try to open the NAV 2009 database which says,

"The extended stored procedure xp_ndo_enumusersids in the library file xp_ndo.dll, is not available on the <server name> server."

Well, if you've faced this above error then the solution for that is very simple. :)
Firstly identify where are those dll files and copy that to your local machine.

You can find xp_ndo.dll and xp_ndo_x64.dll in the following path of NAV 2009 R2 installation folder.
D:\2009R2\SQLDatabase\PFiles\Microsoft Dynamics NAV\60\Database\Cronus.flf


Once you copy the above .dll files in your local folder. Open SQL Server and go to,

Databases -> System Databases -> Master -> Programmability -> Extended stored procedures,

1. Create a new Extended stored procedure in that,

Give a stored procedure name as xp_ndo_enumuserids
and DLL path (the path you the .dll file) - xp_ndo.dll  (This dll file is 32 bit)

Go to permission click search and choose public.
Selecte Execute, Grantor - dbo and tick mark Grant.

2. Again, Create a new Extended stored procedure, go to properties in that,

Give a stored procedure name as xp_ndo_enumusergroups
and DLL path(the path you the .dll file) - xp_ndo_x64.dll  (This dll file is 64 bit)

Go to permission click search and choose public.
Selecte Execute, Grantor - dbo and tick mark Grant.

Fig. below explains in detail.

Once you are done with this go back to your NAV. Try to open the database of 2009R2 and you will be good to go further with your work.


Provider ID Property in Dynamics NAV

You can find this property in "Part" type of the container in Page.

It is applied on a factbox/subpage to establish a link between subpage and the factbox, so that when record changes in subpage, factbox is also updated.

Example..

Consider a document page called Seminar Registration Invoice.




The control id of the part which has linked to "Seminar Reg. Subform"(A listpart page) must be given as a provider id in the factbox(in provider id property of  Seminar Details Factbox ).

So when every you go to next record, the changes will be even affected in Seminar Details Factbox.

This is a very interesting property because there's a link from a repeater or any other controls to a Factbox.

Friday, 15 April 2016

To fix the Mulitple Client issue which is opening for Each run of object

Ever you installed NAV 2016 and if you've faced this problem i.e NAV RTC opens multiple client for each run of object. Then here is a two step solution to solve your problem.

1. Run the command prompt as administrator.
2. Write the following command in your command prompt

C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe /register "C:\Program Files (x86)\Microsoft Dynamics NAV\90\RoleTailored Client\Microsoft.Dynamics.Nav.Client.WinForms.dll" /tlb


key points to be noted:

RegAsm - RegAsm is an Assembly Registration Tool that reads the metadata within an assembly and adds the necessary entries to the registry which allows clients to create .NET framework classes transparently.

tlb(type library file) - Its a file extension for object linking and embedding(OLE) type library file format used by Microsoft Visual C++ software development program.

dll - dynamic link library - Its a microsoft implementation of the shared library concept.
A dll file contains code and data that can be used by multiple programs at the same time, it promotes code reuse and modularization. 


Wednesday, 2 March 2016

NAVY <---- NAVX (Enhancement of Extensions in Dynamics NAV 2016)

There're already lot of blogs that explains about NAVX (Using extensions and events in dynamics NAV without affecting the source code).

This NAVX package will create a new layer on top of NAV I mean it will show the customizations we have done for addons only in SQL server but not in Client of NAV. This is something interesting I found while I was trying to upgrade one of the addons from 2015 to 2016 using a new concept called Extensions in NAV 2016.

But, the upgradation using Extensions didn't make me surprise because I found few things which will not upgrade using this tool.

1. Standard codeunits cannot be modified
2. Reports cannot be upgraded using extensions
3. No customizations can be done on extensions

(If we need to customize again we need to uninstall the NAVX modify the object set in NAV and then install NAVX again, This is something not userfriendly and is not much appreciated.
But, for every problem there's a solution.

Microsoft has came with a new package called NAVY(An enhancement of NAVX).

This NAVY is a package manager for NAV 2015 and NAV 2016. But as of now it has been tested only in NAV 2016.

The features that is included in NAVY are:

You can install, uninstall, suspend, restore or you can even build a NAVY package.


This is something new you can see in NAVY than you saw in NAVX.

Yes, its suspend and restore.

As I said earlier, In NAVX if you need to customize any objects you must uninstall the NAVX package go back to NAV and modify which is risky and time consuming.

But, In NAVY you can suspend a package for sometime which will save the field values in a special tables by removing the  changes from standard objects.

Same way the restore command will installs the changes to standard objects and will restore the field values.

There is already a prerelease software which has been released for our learning purpose but it is still not left anywhere for acual use.

You can install a package to a database,

NAVY install Name=<packagename> DatabaseName=<databasename>
You can download the NAVY prerelease software in my dropbox. Click here to download NAVY