Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dynamics AX 2009 / Axapta dialog validation

385 views
Skip to first unread message

bd

unread,
Nov 9, 2009, 11:57:37 AM11/9/09
to
I've found several posts talking about validating form fields in dialogs, but none of the examples I've found seem to work properly.

Looking for someone to post a complete, concise example of x++ code that generates a dialog containing a single text field, performs simple validation (if text = "abc") on it, and either closes the window (returning the field value) if validation passes or generates an Infolog warning without closing the dialog if validation fails.

For those of us just beginning in x++, I think it would be a great starting point to have an actaul working example to build on.

Thanks!


EggHeadCafe - Software Developer Portal of Choice
Multiple Login Check with Session Pinging
http://www.eggheadcafe.com/tutorials/aspnet/d0a577de-05e1-4834-9b00-105e52d17cd6/multiple-login-check-with.aspx

Klaas Deforche

unread,
Nov 13, 2009, 10:01:02 AM11/13/09
to
Hi there,

Is this what you mean?
If it's not, please provide a link to the other posts you mention.

Just copy/past everything below "******" into a text file, rename it to
".xpo" and import it in AX using the import tool.

Hope this helps.

Best regards,
Klaas.
------------------
http://www.artofcreation.be


******
Exportfile for AOT version 1.0 or later
Formatversion: 1

***Element: CLS

; Microsoft Dynamics AX Class: SimpleDialogTest unloaded
;
--------------------------------------------------------------------------------
CLSVERSION 1

CLASS #SimpleDialogTest
Id 30103
PROPERTIES
Name #SimpleDialogTest
Extends #RunBase
RunOn #Called from
ENDPROPERTIES

METHODS
Version: 3
SOURCE #validate
#public boolean validate(Object _calledFrom)
#{
# boolean ret = super(_calledFrom);
# ;
#
# // do some validation
# if (!theItemId)
# {
# ret = checkFailed("theItemId must be specified.");
# }
#
# return ret;
#}
ENDSOURCE
SOURCE #getFromDialog
#public boolean getFromDialog()
#{
# Boolean ret = super();
# ;
#
# theItemId = dialogTheItemId.value();
# theBoolean = dialogTheBoolean.value();
#
# return ret;
#}
ENDSOURCE
SOURCE #dialog
#protected Object dialog(DialogRunbase _dialog, boolean
_forceOnClient)
#{
# Dialog dialog = super(_dialog, _forceOnClient);
# ;
#
# dialogTheItemId = dialog.addFieldValue(typeId(ItemId),
theItemId);
# dialogTheBoolean = dialog.addFieldValue(typeId(boolean),
theBoolean, "Infolog");
#
# return dialog;
#}
ENDSOURCE
SOURCE #unpack
#boolean unpack(container packedClass)
#{
# Integer packedVersion = conpeek(packedClass, 1);
# Boolean ret = true;
# ;
#
# switch (packedVersion)
# {
# case #CurrentVersion : [packedVersion, #CurrentList] =
packedClass;
# break;
# Default : ret = false;
# }
#
# return ret;
#}
ENDSOURCE
SOURCE #pack
#public container pack()
#{
# return [#CurrentVersion, #CurrentList];
#}
ENDSOURCE
SOURCE #parmtheBoolean
#public boolean parmTheBoolean(boolean _theBoolean = theBoolean)
#{
# if (!prmIsDefault(_theBoolean))
# {
# theBoolean = _theBoolean;
# }
#
# return theBoolean;
#}
ENDSOURCE
SOURCE #parmtheItemId
#public ItemId parmTheItemId(ItemId _theItemId = theItemId)
#{
# if (!prmIsDefault(_theItemId))
# {
# theItemId = _theItemId;
# }
#
# return theItemId;
#}
ENDSOURCE
SOURCE #main
#public static void main(Args _args)
#{
# SimpleDialogTest simpleDialogTest = new SimpleDialogTest();
# ;
#
# if (simpleDialogTest.prompt())
# {
# simpleDialogTest.run();
# }
#}
ENDSOURCE
SOURCE #run
#public void run()
#{
# ;
# if(theBoolean)
# {
# info("checked");
# }
#
# info(theItemId);
#}
ENDSOURCE
SOURCE #description
#static public ClassDescription description()
#{
# return "SimpleDialogTest";
#}
ENDSOURCE
SOURCE #classDeclaration
#class SimpleDialogTest extends RunBase
#{
# ItemId theItemId;
# boolean theBoolean;
#
# DialogField dialogTheItemId;
# DialogField dialogTheBoolean;
#
# #Define.CurrentVersion(1)
# #LocalMacro.CurrentList
# theItemId,
# theBoolean
# #EndMacro
#}
ENDSOURCE
ENDMETHODS
ENDCLASS

***Element: END

0 new messages