gamba90
gamba90

Reputation: 13

Passing parameters of dynamics ax

On Dynamics AX 2012,Passing between two step form a parameter that I would use to change the data source of the second form; how you pass a parameter from the init form to init the data source?

Upvotes: 0

Views: 3191

Answers (3)

Yasir
Yasir

Reputation: 69

One solution of this is to use EnumTypeParameter and EnumParameter property on menuitem of child form. Set these parameter value on parent form and on child form init you just need an if clause then. like:

if (args.parmEnumType() == yourEnum && args.parmEnum() == 'yourEnumValue')
{
   //set the desired datasource
}

these links may help you: opening a form on basis of menuitem and xArgs.parmEnumType

Upvotes: 0

ulisses
ulisses

Reputation: 1569

I hope I have understood the question If you wanto to pass a parameter between forms, you have multiway. One solution. In Form - A override a method clicked() control Button

void clicked()
{
    Args args;
    FormRun formRun;
    ;

    args = new Args();

    args.name(formstr(nameyourFormB));
    args.record(nameTableSourceRecords);
    args.caller(element);
    formRun=new FormRun(args);
    formRun.run();
    formRun.wait();
}

So , in the SecondForm - Form - B override method init()

public void init()
{
    super();
    if(element.args() && element.args().record() &&element.args().record().TableId == tableNum(nameSourceRecords))
    {
        nameTableSourceRecords = element.args().record() ;
        stringEdit.text(nameTableSourceRecords.nameFieldTableSourceRecords);
    }
}

You have to insert in Designs node Form-B a one StringEdite (set AutoDeclaration YES) in Properties.

Now, you open Form-A select a record, click on control Button -> will Open Form-B and you have set a value in your StringEdit control.

I hope to help you. Greetings!

Upvotes: 1

prorook
prorook

Reputation: 76

Get the parameter in the form.init(), save it to a variable in your form's classdeclaration, then override the datasource's init() method and manually create a FormDataSource object using the passed in parameter to determine the datasource.

Although I'm not sure how you're going to show this on form controls...the controls will expect the datasource to be what it is set up as. There's probably a better way to achieve whatever you're trying to do.

Upvotes: 0

Related Questions