Dear experts,
I'm new to x++ & ax world, i have this forms :
I made this forms because i'm learning how to pass values between forms. From many sources i have read, i need to override clicked method in parent form's ok button, and then place code inside init() in child form. But, everytime i clicked ok, form B doesn't show me anything just empty. Can anyone help me solve this? Thanks Here's my code :
Form A :
void clicked(){
FormRun formRun;
Args args;
super();
args = new args();
args.parm(ATable_A.text());
args.name(formStr(bform));
formRun=ClassFactory.formRunClass(args);
formrun.init();
formrun.run();
//formrun.wait();
//formrun.detach();
atable_ds.refresh();
atable_ds.executeQuery();
}
Form B :
public void init(){
str any;
super();
if(element.args()){
any = element.args().parm();
BTable_b.text(any); //why the stringedit or textfield still empty????????????
}}
*This post is locked for comments
Tharindu, why exactly does your code have a case when it's possible not to call super() of init()? The form wouldn't work at all in such a case, which is a serious bug.
Also, as I mentioned above, setting a value directly to the control wouldn't work if it's bound to a datasource.
public void init( )
{
str 50 any;
if(element.args()){
any = element.args().parm(); // get string parameter
super();
BTable_b.text(any); //use any data for your code;
}
}
This should work for you. You have to initialize number of characters to the string.
If you debug the code, you'll (most likely) see that you get an error at the second line.
You didn't tell us where you're using your code, but it seems you try to work with BTable_b object before it was created. Also, if the control is bound to a datasource, you should work with the DS field (also after it gets initialized) instead of with the individual control.
Hi Martin, I've done the same thing of what he is doing I am getting a value however everytime I run this
any = element.args().parm();
BTable_b.text(any);
the form this errors shows up "FormStringControl object not initialized".
For reference, the user's created another thread about a similar same topic.
The method returns an object - the source form. You can save it a variable, call its method etc. - just as with any other object.
Hi Martin,
Thanks for your answer, Martin. I'm trying to find how to use this element.args().caller() but i haven't found the proper answer. Did i use it almost right?
super();
if(element.args())
{
element.args().caller();
}
First of all, always open forms through menu items; do it in code only if there is no other way. Menu items have useful properties such as label and help text, you can configure permissions for menu items etc.
One option is actively pushing values to an Args object, but that's not the only way. Some values are already put there by AX, especially the active record (which is the most common way how to pass data between forms). You can also get a reference to the caller form (by calling element.args().caller() in the target form) and use its methods. Therefore you often don't have to write any code at all in the source form.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,188 Super User 2024 Season 2
Martin Dráb 230,030 Most Valuable Professional
nmaenpaa 101,156