Thursday, December 19, 2013

A Dotnet Variable has not been Instantiated. Attempting to call - Dynamics NAV 2013/ NAV 2009



Hi,
A Dotnet Variable has not been Instantiated. Attempting to call, this error message will pop up when trying to call  a .Net Framework Assembly from CAL code.


when you calling a .Net Framework Assembly without constructor call  you will get above mentioned error message.

constructor is a method that creates an instance of an object and prepares it for use. Before you use a DotNet variable, you should verify whether the variable is static or is an object instance because this determines whether you have to use a constructor.
  • Static variables do not require a constructor because they do not have an instance.
  • Object instance variables require a constructor because they must be created before they can be accessed.
Example Code with constructor Call from CAL code

Asmbly := Asmbly.ConverttoUppercase();                          // Constructor Call
ConvsertyedString := Asmbly.ConverttoUp('marshal');   // Method Call
MESSAGE(ConvsertyedString);


Name DataType               Subtype
Asmbly DotNet                        UpperCase.ConverttoUppercase.'UpperCase, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

Marshal

How to call .Net Framework Assembly member from NAV2013 using CAL code / Extending Microsoft Dynamics NAV Using Microsoft .NET Framework Interoperability

Hi,
Below example will show how to call .Net framework Assembly member from NAV2013R2 using CAL code

1. open Visual Studio and create a class library application
2.Copy and paste below code in class library application

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UpperCase
{
    public class ConverttoUppercase
    {
        public string customername = "";
        public ConverttoUppercase()
        {
        }
        public string ConverttoUp(String Custname)
        {
            customername = Custname.ToUpper();

            return customername;

        }
       
    }

}

3. Build  application (Build -> Build Solution), this will create a dll inside the bin folder of project folder
4. Copy the dll and past it inside "C:\Program Files (x86)\Microsoft Dynamics NAV\71\RoleTailored Client\Add-ins"
5. Create a new code unit 
6. Create a global variable with data type as Dotnet and name it as UperCaseAsmbly
7. Click the assist edit button select recently created dll as sub type
8. Go to the properties of Dotnet variable and change RunOnClient property to yes
9. Create one more global variable with data type text and name it as ConvertedString
10. copy and paste below code in OnRun() of code unit


UperCaseAsmbly := UperCaseAsmbly.ConverttoUppercase(); // Constructor Call
ConvertedString := UperCaseAsmbly.ConverttoUp('marshal'); // Method Call
MESSAGE(ConvsertyedString);

11. Save and run code unit.

above example will convert lowercase letters to uppercase and show in message box.

dll which created in step 2 will have a method "ConverttoUp". This method will accept lower case letters and convert it into uppercase and return the result.

When calling .Net framework Assemblies in CAL code  first need to call the constructors for public variable, it is not needed for static variables


Thanks
Marshal




Thursday, November 21, 2013

How to Create New Company in NAV2013R2 using NAV 2013 R2 administration Shell


Create New Company 
  • Open NAV 2013 R2 Adminstration Shell (Start -> All programs -> NAV 2013 R2 Adminstration Shell ) and enter
  •  New-NAVCompany -ServerInstance DBSRV -CompanyName 'Sample CRONUS'
  • DBSRV is my Server Instance name, replace it by your server Instance
  •  Sample CRONUS Subsidiary is the company which I'm going to create, replace by your company name
  • http://msdn.microsoft.com/en-us/library/dn182571%28v=nav.71%29.aspx

Thanks
Marshal. J

Monday, November 11, 2013

The Call to the member Responsetext msxml3.dll returned following error message. unspecified error - Dynamics NAV

Hi,

you may face following error when trying to hit external web service from Dynamics NAV using
'Microsoft XML, version 2.0'.DOMDocument automation variable.



if you try to get response from external web service before you send request to that particular web service you will face above error. to resolve this you should send request before get response from.below example shows you how to reproduce the error.


Variables Used
Name        DataType       Subtype                                                                         Length
XmlDoc    Automation    'Microsoft XML, version 2.0'.DOMDocument   
HTTP        Automation    'Microsoft XML, version 2.0'.XMLHTTPRequest   

Website Used to hit
http://coinmill.com/AED_INR.html#AED=10

Run below code it will throw an error which is in screen shot, remove the // in 6th line and run again


IF ISCLEAR(XmlDoc) THEN
  CREATE(XmlDoc);
IF ISCLEAR(HTTP) THEN
  CREATE(HTTP);
HTTP.open('POST','http://coinmill.com/AED_INR.html#AED=100',FALSE);
//HTTP.send;
IF HTTP.status = 200 THEN
  MESSAGE('Success');

Sunday, November 10, 2013

There are no NAV Serve Instance Available for this database - Dynamcis NAV 2013R2

Hi
You may face below error when trying to start NAV 2013R2  from developer environment.






Step1
Go to Developer Environment->File->Database->Information and check the server instance and database name,



Step 2
Start Microsoft NAV 2013 Administration and select the Service Instance and check the database name is as same as the database name in Step1, if  database names are different the you will face the above error which mentioned in first screen shot.







To resolve this go to Tools-Options and mention the computer name of the machine which runs NAV server and NAV server Instance  name



and start client from developer environment :)


Thanks
Marshal