Share |

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".