Retrieve Data from .NET Dialog with .NET integration
You can simply retrieve data from .NET Dialogs using NAV .NET Integration.
Example: Object 50002 Get Value from .NET Input Dialog
On Page Action, declare .NET variables
DotNet variables are linked to standard System.Windows.Forms class.
Open Page
Click on Button
Input Data > insert “TEST”
Retrieve Data from .NET Command Prompt
Source C/AL Code
OBJECT Page 50002 Get Value from .NET Input Dial
{
OBJECT-PROPERTIES
{
Date=06/06/16;
Time=10.49.25;
Modified=Yes;
Version List=NAV9;
}
PROPERTIES
{
CaptionML=ENU=Get Value From .NET Input Dialog;
ActionList=ACTIONS
{
{ 1101340000; ;ActionContainer;
CaptionML=ITA=-;
ActionContainerType=NewDocumentItems }
{ 1101340001;1 ;Action ;
Name=Get Value From .NET Dialog Input;
Promoted=Yes;
PromotedIsBig=Yes;
PromotedCategory=Process;
OnAction=VAR
PromptInput@1101340000 : DotNet “‘System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.Windows.Forms.Form” RUNONCLIENT;
PageBordStyle@1101340001 : DotNet “‘System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.Windows.Forms.ButtonBorderStyle” RUNONCLIENT;
PageStartPos@1101340002 : DotNet “‘System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.Windows.Forms.FormStartPosition” RUNONCLIENT;
lblInputData@1101340004 : DotNet “‘System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.Windows.Forms.Label” RUNONCLIENT;
txInputData@1101340008 : DotNet “‘System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.Windows.Forms.TextBox” RUNONCLIENT;
Confirmation@1101340011 : DotNet “‘System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.Windows.Forms.Button” RUNONCLIENT;
DialogResult@1101340012 : DotNet “‘System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.Windows.Forms.DialogResult” RUNONCLIENT;
BEGIN
//Creating .NET Page
PromptInput := PromptInput.Form();
PromptInput.Width := 500;
PromptInput.Height := 300;
PromptInput.StartPosition := PageStartPos.CenterScreen;
//Creating Controls on Page
lblInputData := lblInputData.Label();
lblInputData.Text(‘Enter DataText:’);
lblInputData.Left(70);
lblInputData.Top(70);
PromptInput.Controls.Add(lblInputData);
//Adding Labels and text boxes
txInputData := txInputData.TextBox();
txInputData.Left(200);
txInputData.Top(70);
txInputData.Width(180);
PromptInput.Controls.Add(txInputData);
//Adding Confirmation Button
Confirmation := Confirmation.Button();
Confirmation.Text(‘OK’); //OK
Confirmation.Left(200);
Confirmation.Top(150);
Confirmation.Width(150);
Confirmation.DialogResult := DialogResult.OK;
PromptInput.Controls.Add(Confirmation);
PromptInput.AcceptButton := Confirmation;
// Getting data from prompt dialog
IF (PromptInput.ShowDialog().ToString() = DialogResult.OK.ToString()) THEN
MESSAGE(txInputData.Text); //TEST *** Print message retrieved from prompt
PromptInput.Dispose();
END;
}
}
}
CONTROLS
{
}
CODE
{
BEGIN
{
//Retrieve Data from .NET Dialog Input
//with .NET integration
}
END.
}
}
Salve, ho provato il codice ma ottengo questo risultato:
“Impossibile visualizzare un form o una finestra di dialogo modale quando l’applicazione è in esecuzione in una modalità diversa da UserInteractive”
Utilizzo Dynamics NAV 2016
Grazie