Share |

Thursday, January 14, 2010

How to send a email with attached report from Dynamics NAV

You must previously configure the SMTP, by mean Form 409.

//Create message
cu400.CreateMessage('Sender','sender@mycompany.com',
'recipient1@yourcompany.com;recipient2@yourcompany.com',
'Subject','Body <b>in HTML</b> format.<BR>Regards.',TRUE);
//Generate the report in html format
rpt101.SAVEASHTML(TEMPORARYPATH + 'report101.html');
//Attach file in to email
cu400.AddAttachment(TEMPORARYPATH + 'report101.html');
//Send email
cu400.Send;
//Erase file
ERASE(TEMPORARYPATH + 'report101.html');

Wednesday, December 23, 2009

Shipping mass emails from Navision

One of the main problems of CRM Dynamics NAV (Navision) users is that when making a shipment of a large number of emails, the SMTP server block the account by consider that it is doing SAPM, even if it is not.

One solution is install the SMTP service that comes with Windows, with IS. Although we have to setup, by default is limited in the number of emails that can be sent per session.

Then the server will set to localhost (or internal server name where the SMTP service is installed) so that emails sent through the SMTP of this computer.

Saturday, June 14, 2008

ExpandIT Launch - Execution language

When running ExpandIT Launch Utility does so in the default language of Navision that is English. This may prove a incovenient, for example, by launching reports. The solution is to add this line of code to the report executed, to change the language:
GLOBALLANGUAGE: = 1034
Where, of course, can be replaced 1034 by the language that is preferred.

Sunday, April 13, 2008

Customs VAT

The configuration of group registration VAT, there is a type called 'Total', through which we can load 100% of the amount indicated by both the VAT registration and the account listed in the configuration.

This configuration is particularly useful for loading the Customs VAT , where they we charged the VAT import, and therefore we need to introduce into our records the total amount of VAT indicated.

Advanced users also use this VAT to correct errors (alter) in the registration VAT.

Tuesday, October 30, 2007

Change Caption in execution time

Thanks to nilsm for post in the Tips dBits forum.

Exist a way to change the value of the Caption property in a dynamic way, even for different languages. The trick is to use the control's property CaptionClass control customize the functionality CaptionClassTranslate in CodeUnit 1.

You have a document with detailed explanation in Tips dBits.

Error traceflag 4616 at start NAV in SQL 2005

Thanks to nilsm for post in the Tips dBits forum.

To try execute Dynamics NAV (Navision) in SQL 2005 show the next error:
"The indicator 4616 is not established on the server. This indicator must establish and restart the server before connecting using Microsoft Dynamics NAV."

To correct this situation, proceed as follows:
01.) Open the Start Menu
02.) Go to Microsoft SQL Server 2005 Group
03.) Go to Configuration Tools Group
04.) Click on SQL Server Configuration Manager
05.) Click on SQL Server 2005 Services
06.) Right-click on SQL Server ($INSTANCENAME) and click on Properties
07.) Click on the Advanced tab
08.) Go to Startup Parameters
09.) Enter the string so that it looks as follows (notice the end is the only change):
-dC:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf;-eC:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG;-lC:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf;-T 4616
10.) Click OK
11.) Restart the SQL Server service

Wednesday, June 13, 2007

Correction entries

A field denominated “Correction” exists in journals that can be used to correct, not only the balance of an account, but also the sum of "Debit" and "Credit", since it inserts a entry with a charge or debit (according to it comes) in negative. That is, if it is desired to correct an erroneous movement that it has written 500€ in Debit of an account, by means of this option we will be able to write a movement of correction of -500€ in Debit of the same account, instead of 500€ to the Credit.

This field also exists in the sale and purchase heads, to be able to use it when registering credit memos that in fact are corrections of erroneous invoices.

Thursday, October 12, 2006

Thanks to sergio for "post" in the forum of Tips dBits.

In order to send pulsations of keyboard from Navision and by means of code C/AL we can use this simple trick:

We defined a variable
WShell
of type
Automation
and subtype
'Windows Script Host Object Model'.WshShell

and we used the following code to send the pulsation of a key Enter

IF ISCLEAR(WShell) THEN IF NOT CREATE(WShell) THEN EXIT;
WShell.SendKeys('{ENTER}');


that evidently we can change by the key that we agree more.

Friday, September 01, 2006

Sort a array

C/AL code for sort a array.

OnRun()
myText[1] := 'Z8754';
myText[2] := 'M2532';
myText[3] := 'D1992';
myText[4] := 'A9900';

SortArrayOfText(myText);

FOR i := 1 TO ARRAYLEN(myText) DO BEGIN
 IF myText[i] <> '' THEN
  MESSAGE(myText[i]);
END;


SortArrayOfText(VAR ParamArray : ARRAY [999] OF Text[30])
COMPRESSARRAY(ParamArray);
FOR i := 1 TO ARRAYLEN(ParamArray) DO BEGIN
 IF ParamArray[i] = '' THEN
  Finish := i;
END;

REPEAT
 ToExit := TRUE;
 FOR i := 1 TO (Finish - 1) DO BEGIN
  IF ParamArray[i] > ParamArray[i + 1] THEN BEGIN
   Swap(ParamArray[i], ParamArray[i + 1]);
   ToExit := FALSE;
  END;
 END;
 Finish -= 1;
UNTIL ToExit;


Swap(VAR Param1 : Text[30];VAR Param2 : Text[30])
temp := Param2;
Param2 := Param1;
Param1 := temp;

Friday, August 18, 2006

To avoid strange characters when import / export

When we made imports or exports, by means of dataport for example, we can have the problem to see strange characters in substitution the accents or other signs.

This is because the system used by Navision and Windows is different, Navision uses ASCII system and Windows uses ANSI system, more complete. Although “the normal” characters like A, B, C, ... use he himself code, do not do the special characters previously mentioned. With which the conversion between both system is erroneous.

In order to resolve this disadvantage, Microsoft made available to the users and technicians a CodeUnit that makes the conversion between ANSI system to the ASCII and back. The CodeUnit can be unloaded pressing here.

The CodeUnit offers two methods. Based on if we are importing or exporting we will use a method or another one.

In order to import:
NewText := Ansi2Ascii( myText )

In order to export:
NewText := Ascii2Ansi( myText )

Important. Not use any of these methods if what is tried it is to export and to import again to he himself or another Navision.

Friday, July 21, 2006

Open form by defect

Know you that from C/AL can be opened the form by defect associated to a table? That is, with no need to know his ID. It is only necessary to indicate like parameter of function FORM.RUNMODAL (Number [, Record] [, Field]) a zero and variable of the record to treat.

For example:
recItem.SETFILTER("Gen. Prod. Posting Group", 'MERCADERIA');
FORM.RUNMODAL(0,recItem);
Using the variable recItem of type record and subtype Item and passing it as parameter we obtain that its form associated with the selected data is opened.

Tuesday, May 30, 2006

Send email from Navision

For send email from Navision by means CAL, will use the following code:

Must be declare var objApp like Atomation assigning it to 'Microsoft Outlook 11.0 Object Library'.Application and the var objMail like Atomation assigning it to 'Microsoft Outlook 11.0 Object Library'.MailItem

//Create application
IF ISCLEAR(objApp) THEN CREATE(objApp);

//Create mail item
objMail := objApp.CreateItem(0);

//Set properties
objMail."To"('joseppages@hotmail.com');
objMail.Subject('Mail from Navision');
objMail.Body('This is a mail send from Navision.');

//Uncomment for display email
//objMail.Display();

//Send mail
objMail.Send();

Evidently that through objMail object we have other properties that we can use to our convenience, like CC or Importance.

Monday, March 20, 2006

Pass parameters between objects

Sometimes it is necessary to communicate between objects of Navision with the purpose of transferring additional or complementary information to the called object. The more used option for it is by means pass of parameters, that is, from an object we executed to another object but before we called to a function defined by us.

For example: From the form A we executed form B passing to him some parameters with additional information.

First, in form B we will add a function with the parameters to receive:
SetMyParameters(Param1 : Integer; Param2 : Integer)
MyParameter1 := Param1;
MyParameter2 := Param2;
MyParameter1 and MyParameter2 must be defined as Globals, so that they conserve the value until the object is destroyed.

Add code in event OnOpenForm of form B so check that the vars have the value assigned by means pass of parameters :
Form - OnOpenForm()
MESSAGE('MiParametro1 = %1', miParametro1);
MESSAGE('MiParametro2 = %1', miParametro2);

Second, in form A, and before execute to form B, pass the parameters:
control1000000000 - OnPush()
myFormB.SetMyParameters(1, 2); //Pass parameters to form B
myFormB.RUNMODAL; //The var. MyParameter1 and MyParameter2 have value
CLEAR(myFormB); //The var. MyParameter1 and MyParameter2 NO have value

When execute the line myFormB.RUNMODAL it shown 2 messages inform of value of global vars in form B.

Monday, February 27, 2006

Acces methods to Navision

Due to the persecution of the obtaining of the excellence in the chain of value of the organizations by means of the optimization of business processes (BPM), every time exists more necessity to connect distributed applications, with the purpose of constructing an infrastructure of software based on services (SOA), and this way, to gain in competitiveness, doing this process more efficient, more flexible and less expensive processes and to facilitate, thus also, the decision making (BI).

Navision, like fundamental part of this infrastructure (ERP), has different methods to facilitate its integration in the processes.

Click here for access to powerpoint archive that show this methods.

Thursday, February 02, 2006

Eliminate sessions

Thanks to rvalls for post in forum of Tips dBits.

From version 4.0 of Microsoft Business Navision, it is possible to eliminate sessions, in the native BBDD as in SQL Server. For it will be acceded to the window of "Database sessions", by means of menu File-Database-Information and in the eyelash "Sessions" it will be acceded to the LookUp of "Current sessions". Simply pressing the F4 key, any session will be able to be eliminated, except the present one "My session".