Start Windows Service from NAV

 

ServiceController := ServiceController.ServiceController;

ServiceController.ServiceName(‘Service Name’);

ServiceController.DisplayName(‘Display Name’);

ServiceController.MachineName(‘Machine Name’);

ServiceController.Start;

ServiceController.WaitForStatus(ServiceController.Status.Running);

ServiceController.Refresh;

MESSAGE(TEXT001);

 

TEXT001 – Service Started

ServiceController –   DOTNET   – 

System.ServiceProcess.ServiceController.’System.ServiceProcess,  Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’

 

Consume .NET Webservice (DotNet Data Type)

 

IF ISNULL(DotNetXmlDoc) THEN
DotNetXmlDoc := DotNetXmlDoc.DOMDocumentClass;

IF ISNULL(DotNetXmlHttp) THEN
DotNetXmlHttp := DotNetXmlHttp.XMLHTTPRequestClass;

DotNetXmlHttp.open(‘POST’,’URL’,0,0,0);

DotNetXmlHttp.SetRequestHeader(‘Host’,’ServerName);

DotNetXmlHttp.SetRequestHeader(‘Content-Type’,’text/xml; charset=utf-8′);

DotNetXmlHttp.SetRequestHeader(‘Content-Length’,’Length’);

DotNetXmlHttp.SetRequestHeader(‘SOAPAction’,’http://tempuri.org/MethodName);

DotNetXmlHttp.Send(‘<?xml version=”1.0″ encoding=”utf-8″?>’ +
‘<soap:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/”>&#8217; +
‘<soap:Body>’ +
‘<IsCustomerExist xmlns=”http://tempuri.org/”>&#8217; +
‘<customerID>’+CustomerID+'</customerID>’ +
‘</IsCustomerExist>’ +
‘</soap:Body>’ +
‘</soap:Envelope>’);

DotNetXmlDoc.load(DotNetXmlHttp.responseBody);

IF DotNetXmlHttp.status = 200 THEN BEGIN

DotNetXmlNodeList := DotNetXmlDoc.getElementsByTagName(‘soap:Body’);

DotNetXmlNode := DotNetXmlNodeList.item(0);

EVALUATE(Output,UPPERCASE(DotNetXmlNode.text));

END;

DotNetXmlHttp DotNet MSXML.XMLHTTPRequestClass.’Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’

DotNetXmlDoc DotNet MSXML.DOMDocumentClass.’Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’

DotNetXmlNodeList DotNet MSXML.IXMLDOMNodeList.’Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’

DotNetXmlNode DotNet MSXML.IXMLDOMNode.’Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’

Consume .NET WebService (Automation)

 

CREATE(AutXmlDoc,FALSE,TRUE);

CREATE(AutXmlHttp,FALSE,TRUE);

AutXmlHttp.open(‘POST’,’URL’,0); // If Username PWD then provide with comma separator else 0.

AutXmlHttp.SetRequestHeader(‘Host’,’Server Name’);

AutXmlHttp.SetRequestHeader(‘Content-Type’,’text/xml; charset=utf-8′);

AutXmlHttp.SetRequestHeader(‘Content-Length’,’Length’);

AutXmlHttp.SetRequestHeader(‘SOAPAction’,’http://tempuri.org/Method Name’);

AutXmlHttp.SetTimeouts(10000,10000,10000,0);

AutXmlHttp.Send(‘<?xml version=”1.0″ encoding=”utf-8″?>’ +
‘<soap:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/”>’+
‘<soap:Body>’ +
‘<ValidateAddress xmlns=”http://tempuri.org/”>&#8217; +
‘<Address>’+Address+'</Address>’ +
‘<City>’+City+'</City>’ +
‘<State>’+State+'</State>’ +
‘<Zipcode>’+ZipCode+'</Zipcode>’ +
‘<Country>’+Country+'</Country>’ +
‘</ValidateAddress>’ +
‘</soap:Body>’ +
‘</soap:Envelope>’);

AutXmlDoc.load(AutXmlHttp.responseBody);

IF AutXmlHttp.status = 200 THEN BEGIN

AutXmlNodeList := AutXmlDoc.getElementsByTagName(‘soap:Body’); //Read XML Node

AutXmlNode := locautXmlNodeList.item(0);

EVALUATE(Output,UPPERCASE(locautXmlNode.text));

EXIT(Output);

END;

AutXmlHttp     Automation ‘Microsoft XML, v6.0’.ServerXMLHTTP60

AutXmlDoc      Automation ‘Microsoft XML, v6.0’.DOMDocument60

AutXmlNode    Automation ‘Microsoft XML, v6.0’.IXMLDOMNode

AutXmlNodeList Automation ‘Microsoft XML, v6.0’.IXMLDOMNodeList

Tempblob – How to Use

 

CLEAR(Tempblob);
Tempblob.INIT;
Tempblob.Blob.CREATEOUTSTREAM(Writestream);
XmlString.WRITE(writestream);
Tempblob.INSERT;
Tempblob.CALCFIELDS(Blob);
Tempblob.Blob.CREATEINSTREAM(Readstream);
XMLPORT.IMPORT(XMLPORT::”Name of Xmlport”,Readstream);

Variable – DataType
Tempblob – Record – Tempblob
XmlString – Bigtext
Writestream – OutStream
Readstream – InStream

NAV 2013 – Open as a Fresh User with Default Settings.

 

Sometimes doing an operation from SQL side is much easier then exceuting it from NAV itself. If you want to use NAV as a fresh user with all default settings then you just need to execute a dell or truncate SQL command for these Tables

 USE [DBName]; 
 delete FROM [Access Control];  
 delete FROM [User];  
 delete FROM [User Property];  
 delete from [User Personalization];  
 delete from [User Metadata];  

              OR
 USE [DBName]; 
 Truncate Table [Access Control]; 
 Truncate Table [User]; 
 Truncate Table [User Property]; 
 Truncate Table [User Personalization]; 
 Truncate Table [User Metadata]; 

 Enjoy.

Quick Filter in Microsoft Dynamics NAV

 

 

With the introduction of Microsoft Dynamics NAV 2013, Microsoft had changed the Quick filter functionality and this blog post is a summarize version of the article published in the MSDN Blog.
The following table illustrates more Quick Filter search examples in Microsoft Dynamic NAV 2013.

 

Search Criteria Interpreted as… Returns…
Man @man* All records that start with the string man and case insensitive.
Se @se* All records that start with the string se and case insensitive.
Man* Starts with Man and case sensitive All records that start with the string Man
‘man’ An exact string and case sensitive All records that match man exactly
*1 Ends with 1 All records that end with 1
@*man Ends with and case insensitive All records that end with man
@man* Starts with and case insensitive All records that start with man

The following table illustrates the Quick Filter search examples for the Cumulative Update 13 and later for Microsoft Dynamics NAV 2013 and Microsoft Dynamics NAV 2013 R2.

 

Search Criteria Interpreted as… Returns…
Man @*man* All records that contain the string man and case insensitive.
Se @*se* All records that contain the string se and case insensitive.
Man* Starts with Man and case sensitive All records that start with the string Man
‘man’ An exact string and case sensitive All records that match man exactly
*1 Ends with 1 All records that end with 1
@*man Ends with and case insensitive All records that end with man
@man* Starts with and case insensitive All records that start with man

Enjoy.

 

Upload License

 

Method 1.

1. Open Development Environment + Object Designer.
2. Navigate – Tools -> License Information.

3. Once you press License Information, Following window will get displayed which will show the description of the current license running.

4. Now to change the License simply press change and choose the destination folder from where you want to Import. Just remember you have just changed the License so it’s just temporary. To permanently change the License you need to upload this to your Database.

5. Now again Navigate to same place, Tools -> License Information but this time instead of changing License choose upload button to upload the License. This will get saved in your Database and any time you open, you will be in your Development environment with this License.

6. Once it’s uploaded you will get following confirmation message.

 

Method 2

1. Navigate to File -> Database -> Alter

2. Push Integration tab. You will see “Save license in database”. Choose and press OK.

3. Now follow the process as stated above.

NOTE –  MUST RESTART YOUR DYNAMICS NAV SERVICE ONCE LICENSE UPLOADED.

Enjoy.