A short tutorial on how to open a form in Dynamics Ax (Axapta) by code.
In the shortest example, all it takes is one line of code.
new MenuFunction(MenuItemDisplayStr(CustTable),MenuItemType::Display).run();
The above code will open the CustTable form. That's all it takes, it's that simple.
Now if you want to supply some arguments to the opening form, this is also possible with the optional args parameter.
Like this for example:
static void OpenFormByCodeA()
{ Args args = new Args();
;
args.record(CustTable::find('ABC'));
new MenuFunction(MenuItemDisplayStr(CustTable),MenuItemType::Display).run(Args);
}
This code will open the CustTable form and filter out the customer with accountnumber ABC.
Use the args methods like parm and parmEnum to provide your target form with more data.
If you want even more control on opening the form from code, this is also possible.
This next example gives the same result as the previous one.
static void OpenFormByCodeB()
{ FormRun formRun;
Args args = new Args();
;
args.name(formstr(CustTable));
args.record(CustTable::find('ABC'));
formRun = ClassFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.wait();
}
Now if we tweak this a little bit, we can add our code
Like this:
static void OpenFormByCodeB()
{ Object formRun;
Args args = new Args();
;
args.name(formstr(CustTable));
args.record(CustTable::find('ABC'));
formRun = ClassFactory.formRunClass(args);
formRun.init();
formRun.yourmethodgoeshere(); /* !!
formRun.run();
formRun.wait();
}
By changing the type of formRun from class FormRun to class Object, we can implement and execute extra methods on our destination form! This gives us extra possibilities for customizations. You can pass along extra parameters for example.
Only drawback: While programming, your method doesn't show up in the IntelliSense, showing all the available methods. So be carefull of typo's. (They don't give a compile error, but they will give you a run-time error.)
Next up: Run a report by code
Wednesday, September 23, 2009
Subscribe to:
Post Comments (Atom)
Thank You!!!!
ReplyDeleteThank you so much!!
ReplyDeleteI've been looking for this line of code for hours :-(
You Made My Morning
ReplyDeleteboss i have query,we have multiple company in ax 2009,when i create sales order for a company so for some company the delivery address value data insert in to street field from which automatic fetch that data into delivery address field by default,which meet our requirements,but for one company this process can not be occur ,that is no data can fetch from street field to delivery address which create inconsistency in sales confirmation report..
Deletesir please help me ,
Hi, I like your blog a lot. I've learned much from your work.
ReplyDeleteBut my question is about running a form that is already in favorities window.
How to run a form with a user query that is already pin to particular form?
Any ideas?
Best regards
Jacek Witkowski
It helps me a lot!!
ReplyDeleteIs it possible with this code or some similar code to open from WPF application AX form?
ReplyDeleteAhh ! A master class of a true mentor ! Greatly done ! THANK YOU !
ReplyDeleteboss i have query,we have multiple company in ax 2009,when i create sales order for a company so for some company the delivery address value data insert in to street field from which automatic fetch that data into delivery address field by default,which meet our requirements,but for one company this process can not be occur ,that is no data can fetch from street field to delivery address which create inconsistency in sales confirmation report..
ReplyDeletesir please help me ,
boss i have query,we have multiple company in ax 2009,when i create sales order for a company so for some company the delivery address value data insert in to street field from which automatic fetch that data into delivery address field by default,which meet our requirements,but for one company this process can not be occur ,that is no data can fetch from street field to delivery address which create inconsistency in sales confirmation report..
ReplyDeletesir please help me ,
thanks
ReplyDeleteSubscribe to learn this new technique in Ax . Give like comments and share
ReplyDeletehttps://youtu.be/8dXjRzSk910
elazığ
ReplyDeletegümüşhane
kilis
siirt
sakarya
6143D
sakarya
ReplyDeletedüzce
çankırı
sivas
elazığ
F6SQ2
6BA6F
ReplyDeleteYenimahalle Fayans Ustası
Çerkezköy Çilingir
Ağrı Evden Eve Nakliyat
Trabzon Lojistik
Probit Güvenilir mi
Aksaray Şehir İçi Nakliyat
Hakkari Şehir İçi Nakliyat
Çankırı Lojistik
Bolu Şehirler Arası Nakliyat
41EB0
ReplyDeletehttps://referanskodunedir.com.tr/
50CA7
ReplyDeletekomisyon indirimi %20
C0280
ReplyDeletekonya en iyi ücretsiz sohbet uygulamaları
amasya random görüntülü sohbet
mersin canlı sohbet sitesi
burdur yabancı sohbet
ısparta en iyi sesli sohbet uygulamaları
canli sohbet
ordu yabancı görüntülü sohbet uygulamaları
karaman sesli sohbet uygulamaları
kocaeli telefonda rastgele sohbet
10CDE
ReplyDeleteNevşehir Telefonda Canlı Sohbet
Bitlis Yabancı Görüntülü Sohbet Uygulamaları
Afyon Sesli Sohbet Odası
en iyi ücretsiz görüntülü sohbet siteleri
canli sohbet bedava
balıkesir ücretsiz sohbet uygulamaları
Karaman Sesli Sohbet Sesli Chat
erzurum sesli sohbet uygulamaları
bitlis mobil sesli sohbet
9D447
ReplyDeleteyearn finance
zkswap
sushiswap
quickswap
dappradar
uwulend finance
DefiLlama
pudgy penguins
satoshivm
20F31
ReplyDeletepancakeswap
DefiLlama
yearn finance
quickswap
shapeshift
phantom wallet
eigenlayer
dappradar
defillama
ewrfgfdhgbfhn
ReplyDeleteشركة مكافحة الحمام بالاحساء
GFTHGJNYHGMK
ReplyDeleteشركة صيانة افران
07F6DADA9A
ReplyDeletewhatsapp güvenilir show
شركة مكافحة النمل الابيض nsRbAgX80y
ReplyDeleteشركة تسليك مجاري بالخبر Q73U7ebTt9
ReplyDelete