Hi
I created a class for dialog and there i need to add a lookup. Something like
AddressState::lookupStateId(dialogFieldNewState.control(), custInvoiceTable.CountryRegionId);
Kindly help!
Hi
I created a class for dialog and there i need to add a lookup. Something like
AddressState::lookupStateId(dialogFieldNewState.control(), custInvoiceTable.CountryRegionId);
Kindly help!
Please visit the following link: http://msdax.blogspot.com/2007/08/overriding-method-for-control-in-dialog.html
You can refer to Tutorial_RunbaseForm class (AOT). It has custaccount lookup.
But i need to filter that lookup also, something like making use of
Fld3_1_lookup()
{
//i wrote the filter code here
} but im not sure how to call or use it
Tutorial_RunbaseForm class is in turn calling a tutorial_RunbaseForm form. In order to filter the look up, you can add a look up method .
For example In the above form you have a edit display method ‘editCustAccount’ .Now if you want to apply filter to this look up, you can add a look up to this field.
formStringControl = element.design().controlname(“editCustAccount”);
qdb = query.addDataSource(tablenum(Table));
sysTableLookup = SysTableLookup::newParameters(tablenum(Table), formStringControl);
sysTableLookup.addLookupfield(fieldnum(Table,Field));
…
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
This will get automatically called when you try to open the look up field. its a edit display method. Check out both tutorial class and form and add look up method to the field where u want to apply filter.
Thanks Monika!
I have understood the logic. Thats a good way way to deal with the issue.
Could you tell me how to achieve the same using Fld3_1_lookup() method. I saw some classes imoplementing the same e.g. fld900_1_lookup() in TransactionReversal_cust class in AX 5
I will have to look into it. Will let u know if I find something.
You can refer the following example:
boolean Fld3_1_lookup(FormControl _formControl, str _filterStr)
{
SysTableLookup sysTableLookup
QueryBuildDataSource queryBuildDataSource;
Query query;
QueryBuildRange queryRangePhysical,queryRangeTechnical;
FormStringControl _control = dialog.formRunClient().controlCallingMethod();
;
_formControl=_control;
sysTableLookup = SysTableLookup::newParameters(tablenum(iDMS_N_AMAsset), _formControl);
sysTableLookup.addLookupfield(fieldnum(iDMS_N_AMAsset, AssetId),true);
sysTableLookup.addLookupfield(fieldnum(iDMS_N_AMAsset, PhysicalLocationId));
sysTableLookup.addLookupfield(fieldnum(iDMS_N_AMAsset, TechnicalLocationId));
query = new Query();
queryBuildDataSource = query.addDataSource(tablenum(iDMS_N_AMAsset));
queryBuildDataSource.relations(true);
queryRangePhysical = queryBuildDataSource.addRange(fieldnum(iDMS_N_AMAsset, PhysicalLocationId));
if(dialogTechnicalLocation.value())
queryRangeTechnical= queryBuildDataSource.addRange(fieldnum(iDMS_N_AMAsset, TechnicalLocationId));
queryRangePhysical.value(SysQuery::value(dialogPhysicalLocation.value()));
if(dialogTechnicalLocation.value())
queryRangeTechnical.value(SysQuery::value(dialogTechnicalLocation.value()));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
return true;
}
@monika: Thanks a lot.
@Vinay: could you tell what are the methods i need to overload in that class?
For the lookup purpose you need to modify only one method and the method name will be the combination of field name and ‘lookup’ as
field3_1_lookup()
{
}
The below is the class
+++++++++++++++++++++++++++++++++++++
Exportfile for AOT version 1.0 or later
Formatversion: 1
***Element: CLS
; Microsoft Dynamics Class: DialogExample unloaded
; --------------------------------------------------------------------------------
CLSVERSION 1
CLASS #DialogExample
PROPERTIES
Name #DialogExample
Extends #RunBase
RunOn #Called from
ENDPROPERTIES
METHODS
Version: 3
SOURCE #classDeclaration
#public class DialogExample extends RunBase
#{
#}
ENDSOURCE
SOURCE #dialog
#Object dialog()
#{
#}
ENDSOURCE
SOURCE #dialogPostRun
#public void dialogPostRun(DialogRunbase dialog)
#{
#}
ENDSOURCE
SOURCE #Fld2_1_lookup
#void Fld2_1_lookup()
#{
#breakpoint;
#}
ENDSOURCE
SOURCE #getFromDialog
#boolean getFromDialog()
#{
#}
ENDSOURCE
SOURCE #pack
#public container pack()
#{
#}
ENDSOURCE
SOURCE #parmName
#Name parmName()
#{
#}
ENDSOURCE
SOURCE #unpack
#public boolean unpack(container _packedClass)
#{
#}
ENDSOURCE
SOURCE #main
#public static void main(Args args)
#{
#}
ENDSOURCE
ENDMETHODS
ENDCLASS
***Element: END
+++++++++++++++++++++++++++++++++++++++++++++++++++++
State_LNT is an EDT where relation exist State_LNT == AddressState.StateId
I am Calling the class from the job below
++++++++++++++++++++
Exportfile for AOT version 1.0 or later
Formatversion: 1
***Element: JOB
; Microsoft Dynamics Job: dialog unloaded
; --------------------------------------------------------------------------------
JOBVERSION 1
SOURCE #dialog
#static void dialog(Args _args)
#{
#}
ENDSOURCE
***Element: END
++++++++++++++++++++++++++++
I have modified the XPO according to the need.Now you can see the lookup on current state field and the filtration will be done on the basis of values supplied in the state variable of lookup method.XPO is as following
Exportfile for AOT version 1.0 or later
Formatversion: 1
***Element: FRM
; Microsoft Dynamics AX Forms unloaded
; --------------------------------------------------------------------------------
FRMVERSION 5
FORM #tutorial_RunbaseForm
PROPERTIES
Name #tutorial_RunbaseForm
ENDPROPERTIES
METHODS
Version: 3
SOURCE #classDeclaration
#public class FormRun extends ObjectRun
#{
#}
ENDSOURCE
SOURCE #CloseOk
#void closeOk()
#{
#;
#}
ENDSOURCE
SOURCE #init
#public void init()
#{
#;
#}
ENDSOURCE
SOURCE #runBase
#//AOSRunMode::Client
#RunBase runBase()
#{
#}
ENDSOURCE
SOURCE #editCustAccount
#//BP Deviation Documented
#edit CustAccount editCustAccount(
#{
#}
ENDSOURCE
ENDMETHODS
OBJECTBANK
PROPERTIES
ENDPROPERTIES
ENDOBJECTBANK
JOINS
ENDJOINS
DESIGN
PROPERTIES
Caption #@SYS70984
HideToolbar #Yes
HTMLHelpFile #HTMLHelpFileIWorker
HTMLHelpTopic #AxShared.chm::/html/a3a4b12f-311c-4b56-9752-c5fecf31ce54.htm
StatusBarStyle #Simple
ENDPROPERTIES
CONTAINER
CONTROL TAB
PROPERTIES
Name #Tab
Tabs #1
ENDPROPERTIES
CONTAINER
CONTROL TABPAGE
PROPERTIES
Name #TabPage
Caption #@SYS2952
ENDPROPERTIES
CONTAINER
CONTROL GROUP
PROPERTIES
Name #dialogStartGrp
HTMLHelpFile #HTMLHelpFileAxShared
HTMLHelpTopic #html/4D2CF679-8360-4271-85B8-9079AC40098F.htm
FrameType #None
ENDPROPERTIES
CONTAINER
ENDCONTAINER
ENDCONTROL
CONTROL BUTTONGROUP
PROPERTIES
Name #RightButtonGrp
ENDPROPERTIES
CONTAINER
ENDCONTAINER
ENDCONTROL
ENDCONTAINER
ENDCONTROL
ENDCONTAINER
ENDCONTROL
CONTROL BUTTONGROUP
PROPERTIES
Name #BottomButtonGrp
Left #Auto (right)
Top #Bottom edge
ArrangeMethod #Horizontal, flush right
ENDPROPERTIES
CONTAINER
CONTROL COMMANDBUTTON
PROPERTIES
Name #CommandButtonOK
Command #263
ENDPROPERTIES
ENDCONTROL
CONTROL COMMANDBUTTON
PROPERTIES
Name #CommandButtonCancel
Command #264
ENDPROPERTIES
ENDCONTROL
ENDCONTAINER
ENDCONTROL
ENDCONTAINER
ENDDESIGN
ENDFORM
<Table:Record name=“TmpSysLabel”
xmlns:Table=‘urn:www.microsoft.com/Formats/Table’>
<Table:Field name=“Language”>en-us</Table:Field>
<Table:Field name=“Label”>This tutorial must be started by the class: Tutorial_Runbaseform</Table:Field>
<Table:Field name=“Description”></Table:Field>
<Table:Field name=“LabelId”>@SYS90597</Table:Field>
<Table:Field name=“SysLabelApplModule”>0</Table:Field>
<Table:Field name=“recVersion”>0</Table:Field>
</Table:Record>
<Table:Record name=“TmpSysLabel”
xmlns:Table=‘urn:www.microsoft.com/Formats/Table’>
<Table:Field name=“Language”>en-us</Table:Field>
<Table:Field name=“Label”>Tutorial</Table:Field>
<Table:Field name=“Description”>Means autodidaction.</Table:Field>
<Table:Field name=“LabelId”>@SYS70984</Table:Field>
<Table:Field name=“SysLabelApplModule”>0</Table:Field>
<Table:Field name=“recVersion”>0</Table:Field>
</Table:Record>
<Table:Record name=“TmpSysLabel”
xmlns:Table=‘urn:www.microsoft.com/Formats/Table’>
<Table:Field name=“Language”>en-us</Table:Field>
<Table:Field name=“Label”>General</Table:Field>
<Table:Field name=“Description”>General</Table:Field>
<Table:Field name=“LabelId”>@SYS2952</Table:Field>
<Table:Field name=“SysLabelApplModule”>0</Table:Field>
<Table:Field name=“recVersion”>0</Table:Field>
</Table:Record>
***Element: JOB
; Microsoft Dynamics AX Job: dialog unloaded
; --------------------------------------------------------------------------------
JOBVERSION 1
SOURCE #dialog
#static void dialog(Args _args)
#{
#}
ENDSOURCE
***Element: CLS
; Microsoft Dynamics AX Class: DialogExample unloaded
; --------------------------------------------------------------------------------
CLSVERSION 1
CLASS #DialogExample
Id 50039
PROPERTIES
Name #DialogExample
Extends #RunBaseBatch
RunOn #Called from
ENDPROPERTIES
METHODS
Version: 3
SOURCE #classDeclaration
#public class DialogExample extends RunBaseBatch
#{
#}
ENDSOURCE
SOURCE #dialog
#Object dialog()
#{
#}
ENDSOURCE
SOURCE #dialogPostRun
#public void dialogPostRun(DialogRunbase _dialog)
#{
#}
ENDSOURCE
SOURCE #Fld2_1_lookup
#void Fld2_1_lookup()
#{
#}
ENDSOURCE
SOURCE #getFromDialog
#boolean getFromDialog()
#{
#}
ENDSOURCE
SOURCE #pack
#public container pack()
#{
#}
ENDSOURCE
SOURCE #parmName
#Name parmName()
#{
#}
ENDSOURCE
SOURCE #run
#void run()
#{
#}
ENDSOURCE
SOURCE #unpack
#public boolean unpack(container _packedClass)
#{
#}
ENDSOURCE
SOURCE #main
#public static void main(Args args)
#{
#}
ENDSOURCE
ENDMETHODS
ENDCLASS
***Element: PRN
; Microsoft Dynamics AX Project : A_DialogFilter unloaded
; --------------------------------------------------------------------------------
PROJECTVERSION 2
PROJECT #A_DialogFilter
SHARED
PROPERTIES
Name #A_DialogFilter
ENDPROPERTIES
PROJECTCLASS ProjectNode
BEGINNODE
FILETYPE 0
UTILTYPE 11
UTILOBJECTID 0
NODETYPE 201
NAME #tutorial_RunbaseForm
ENDNODE
BEGINNODE
FILETYPE 0
UTILTYPE 5
UTILOBJECTID 0
NODETYPE 215
NAME #dialog
ENDNODE
BEGINNODE
FILETYPE 0
UTILTYPE 45
UTILOBJECTID 50039
NODETYPE 329
NAME #DialogExample
ENDNODE
ENDPROJECT
***Element: END
@Vinay: Thanks for the effort I really appreciate it.
Just one last question, why we make use of the tutorial_RunbaseForm
dialog = Dialog::newFormnameRunbase(formstr(tutorial_RunbaseForm),this);
Cant we design one without using it?
There is no need of tutorial_RunbaseForm as such.I have just initialized this form so that my new dialog fields will be added to this form only.You can use the following code instead of tutorial_RunbaseForm.
dialog = super();
The whole code of dialog method is as follows:
Object dialog()
{
;
dialog = super();
// dialog = Dialog::newFormnameRunbase(formstr(tutorial_RunbaseForm),this);
// Add a field for a name to the dialog. This will populate the field with
// any value that happens to be saved in name from previous uses of the
// dialog.
dialogName = dialog.addFieldValue(TypeId(Name), name);
dialogFieldCurrentState = dialog.addField(TypeID(State_LNT),"Current State: ");//State_LNT
dialogFieldNewState = dialog.addField(TypeID(State_LNT),"NewState: ");
return dialog;
}
ok that works great. Now i want to remove the batch tab.
I am a newbie to ax when i see ur code and the modifications you do I just wander how you do it? great job thanks once again
There is no magic in writing the code.Don’t worry you will learn it gradually.As you told that you want to remove the Batch tab from the dialog so for that purpose you need to override the canGoBatch() method as following-
public boolean canGoBatch()
{
boolean ret =false;
return ret;
}
Every time I try to implement this, I am getting a Stack Trace error, saying that my FormRun object is not initlaized. I’ve got this code copied exactly as it is, but it’s not working.
Any reasons as to why this isn’t executing properly would be greatly appreciated.