boucekv
boucekv

Reputation: 1230

How to set position on caller when the child with open mode new is closing?

I have a form with record. To create new one I have menuitem button which opens a new Form where you can create new record (and there is lots of logic which will not be easy to move into new record action on parent datasource). This menuitem has OpenMode = New so the new record is created in datasource.

When I am closing this new form I want to set caller to newly created record. I was trying to do it by.

    TableName TableName;
    FormDataSource FormDataSource;
    boolean test;
    #Task
    element.args().caller().task(#taskF5);
    FormDataSource = element.args().caller().dataSource('CallerDataSourceName');
    FormDataSource.research();
    TableName= getFirstSelection('ThisDatasourceName');
    test = FormDataSource.findRecord(TableName);

The result of the findRecord is true and it looks like it is set the position for a second after second the position on grid switch to the 1. (And the result of the test is true.)

I move the seting position to the caller but it does not help. Is the problem in the menuitem open mode property? How can I ensure the position on the caller?

I am using AX2012

Upvotes: 0

Views: 916

Answers (1)

boucekv
boucekv

Reputation: 1230

I end up with this solution. I am not setting position on the child but on the caller.

On a child I have this (+ hasMethod):

tableToFind = getFirstSelection(SQLTables_DS);
element.args().caller().setRecord(tableToFind);

it is in close under the super();

On the caller I have method:

public void setRecord(TableName _TableName)
{
boolean test;    

CallerDataSourceName_DS.research();
test = CallerDataSourceName_DS.findRecord(_TableName);
CallerDataSourceName.refresh();
}

The same trick on the child in close does not work. I guess it is due to the OpenMode property.

Upvotes: 1

Related Questions