Monday, October 28, 2013

Download Dynamics NAV 2013 R2

How to access SQL object From Dynamics NAV 2009

Hi
Following example will show how to access a sql view from Dynamics NAV 2009
  • Create a SQL view
  • Create a Table in NAV field names as same as field names in sql view
  • go to the report properties and change "LinkedObject" to yes
  • save the Table . Table name should be as same as view name
  • run Table
Create View in sql

CREATE VIEW [CRONUS International Ltd_$SamView] AS
SELECT [No_],[Name]
FROM [Demo Database NAV (6-0)].[dbo].[CRONUS International Ltd_$Customer]

Create Table in NAV






save table and run it :)

Thanks
Marshal. J


Sunday, October 20, 2013

How Create linked Reports in NAV 2013/RTC

Hi all,
below example will show how to link a Report/Page to another report, lets assume customer summary report needs to be linked with customer trial balance, so that user clicks the amount field in customer summary report then customer detail trial balance should run automatically and show the balance

  • Create a report using Customer table as data item as like below

  • Go to View -> Layout
  • Design the report as like bvelow

  • Go to the properties of the [Balance] column -> Action -> URL
  •  paste below code at Select URL field , First one will run report without any filter
  • ="DynamicsNAV:////runReport?Report=104
  • ="DynamicsNAV:////runReport?Report=104&$filter=Customer.'No.'%20IS%20'"+Fields!CustomerNo.Value+"'"
  • Save and run the report from NAV above code will run report 104 when the user clicks the amount field of newly created report
  • Applicable for Dynamics NAV  2009 RTC Client/ NAV 2013


Thanks
Jerome Marshal. J






How to convert Duration to Integer Dynamics NAV

Hi All

Below example will convert the duration variable to integer, Normally in  Dynamics NAV duration data type will display the data as  like  "5 Days 7 Hours 35 Minutes 12 seconds". Even some times it will include Milli seconds too so how to convert this into integer to calculate the exact hours spent

Name               DataType    Subtype    Length
ProcessStart     DateTime       
ProcessEnd      DateTime
TimeDuration  BigInteger
TotalHours       Integer        


ProcessStart := CREATEDATETIME(010109D,072005T);
ProcessEnd := CREATEDATETIME(300109D,103000T);
TimeDuration := ProcessEnd - ProcessStart;
TotalHours := TimeDuration/3600;
Message('%1',TotalHours);

above code will give the exact time (hours) spent in a process.

Saturday, October 19, 2013

Microsoft.Dynamics.Nav.Types.NavDatabasePasswordException Dynamics NAV/ RTC/WebService

Hi All,
You may face this error when run RTC client or access NAV application using web services. and more over this error you will face in 3 tire installation

Cause
 if below mentioned services are not delegated properly then the users of RTC client will get an error stating that  "Microsoft.Dynamics.Nav.Types.NavDatabasePasswordException Dynamics NAV/ RTC/WebService"

since the services are not delegated then the user name which is used to log On the service only can connect RTC or WebServices

NAV Services are 
Dynamics NAV Server
Dynamics NAV Business Webserives

Solution
Delegate the services correctly
 
Setting up Delegation
http://msdn.microsoft.com/en-us/library/dd301254.aspx

 

How to Write Log File using CAL code - Dynamics NAV

Hi All
How to create a log file in Dynamics NAV try below steps, this sample code create a new log file (Log) in C:\
  • Create a new codeunit
  • Create following variables
  • Name                 DataType    Subtype    Length
    TestFile              File       
    TestStream        OutStream 
  • Paste below code at OnRun() save and run the codeunit     



TestFile.CREATE('C:\Log.txt');
TestFile.WRITEMODE(TRUE);
TestFile.OPEN('C:\log.txt');
TestFile.CREATEOUTSTREAM(TestStream);
TestStream.WRITETEXT (‘Success');
TestFile.CLOSE;
Message('Log Created Successfully')

Thanks
Marshal. J

Difference Between Form.Run and Form.RunModal - Dynamics NAV

Hi All,

What is the difference between Form.Run and Form.RunModal ?

Form.Run : if Form.Run used to run a form then NAV application  will allow the user to access other forms
Form.RunModal : if Form.RunModal used to run a form then NAV application will not allow the user to move other forms still close the current form


Thanks
Jerome Marshal

Friday, October 18, 2013

How to Shrink Log File - Dynamics NAV SQL Database

Hi All,
Following example will show how to shrink the log file when the database reached maximum size, there is an alternate way is available to resolve this problem.

if your SQL database for Dynamics NAV reached maximum size then you have two options

Option 1

1. Expand the database size (File -> Database -> Expand)
2.Enter new size in Expand Database screen

Option 2
run below query to shrink log file 

USE NAVDemo
GO
DBCC SHRINKFILE(NAVDemo_Log, 1)
BACKUP LOG NAVDemo WITH TRUNCATE_ONLY
DBCC SHRINKFILE(NAVDemo_Log, 1)
GO 


Replace NAVDemo by your database Name



Thanks
Jerome Marshal .J

Export To Excel using Automation Dynamics NAV

Hi All
 following example will show how to export to excel using automation variables, create a new report and place the code in respective triggers and create automation variables and run report

Variables you need
Name                         Data Type                               SubType
1.Excel                   Automation                                 'Microsoft Excel 12.0 Object Library'.Application
2.Book                  Automation                                  'Microsoft Excel 12.0 Object Library'.Workbook
3.Range                 Automation                                  'Microsoft Excel 12.0 Object Library'.Range
4.Sheet                  Automation                                  'Microsoft Excel 12.0 Object Library'.Worksheet
5.I                         Integer
6.J                        Text

Now place the following code at respective triggers
OnPreDataItem()  {To Create work sheet}
CREATE(Excel);
Excel.Visible(TRUE);
Book:=Excel.Workbooks.Add(-4167);
Sheet:=Excel.ActiveSheet;
Sheet.Name := 'Customer List';
OnAfterGetRecord()   {To assign Values to the excel cells}
Sheet.Range('A'+j).Value := Customer."No.";
Sheet.Range('B'+j).Value := Customer.Name;
j:=INCSTR(j);
OnInitReport();
j:='1';

Now Design your report and run.Thanks
Jerome Marshal.J

Set Group Level Serial Number in RTC/ Visual Studio/ NAV2013 Reports

  •  Add a text box to left side of the grouping field
  • In Visual Studio Go to Report -> Report Properties->Select Code Option
  • Paste the below  code
Public Sno AS Decimal
Public Function GetSno(ByVal GroupName As String) As String
   Dim strBuilder As New System.Text.StringBuilder(GroupName )
   If GroupName .Contains("Group1") Then
      Sno = Sno +1
      Return Sno      
   Else
      Return ""
   End If
End Function   
  • Replace the Group1 by your group's Name (Go to the group Property to know the group name)
  • Click OK
  • Go To the Expressions of the newly added text box and type
  • =code.GetSno("Group1")
  • Here Replace the Group1 your group's Name (Go to the group Property to know the group name)
  • Save and run
  • Ref the screenshot below


Thanks
Marshal. J

jmarshal84@gmail.com