copy data from grid in form to another form with different datasource

Dear All,

Greetings, simply i forget how i can create instance from form to access method in it because when i wan in another form and try to declare an abject from form in any method in that form i received error,

second i have grid that content of invoice id and check box to choose one of invoices, i want when i check the box to select invoice take these selected invoices to another form with another datasource but has invoice id that i need to paste it ,help me ASAP , appreciated your help ,many thanks.

Regards,

Hisham.

  1. If you declare a variable of type “object”, there is no compile-time check so you can call any method. You can keep strong-type validations if you move the method to a class “owned” by the original form.

  2. It depends how do you save these checkboxes. In general, you need to pass a reference to the data structure containing the data - by the Args object or by a method call.

Dear ,

Greetings, for first point can you send snpit of code to clarification , second point i tried send throw Args object like an Array[ ] and send it by parameter but the problem was how i can make loop on grid to choose only selected rows “Invoice” ,by the way i save the check box as “NoYesId” Enum in “LeadgerJouranlTrans” Table as a flag “Invoice pool” from my issue after select press a bottun to pass values to another form and open it which i write code in Create() method to create a new sequence the code in below

for invoice pool form

Void Click()

{

Args args;
FormRun formRun;
// Our custom made class for passing complex set of parameters
FormBParams formBParams = new FormBParams();
Array items = new Array( Types::String );
int i;
;

args = new args();

for( i=0; i<LedgerJournalTrans_DS.numberOfRowsLoaded(); i++ )
{
items.value( i+1, int2str( DS_SelectToConsign.value(i)));
Info(int2str(LedgerJournalTrans_DS.numberOfRowsLoaded()));
}
formBParams.parmItems( items );
// Pass our object to FormB
args.parmObject( DS_AddToConsignment );

// Run FormB
args.name( formstr( DS_AddToConsignment ) );
formRun = classFactory.formRunClass( Args );
formRun.init();
formrun.run();
formrun.wait();

if( formrun.closedOk() )
{
DS_AddToConsignment.text( args.parm() );
}

super()

}

in the another form in create method

public void create(boolean _append = false,boolean extern=false)
{
DS_TmpInvoice DS_TmpInvoice;
;
element.numberSeqFormHandler().formMethodDataSourceCreatePre();

super(_append);

if (!extern)
{
// Info(DS_TmpInvoice.DS_Invoice);
element.numberSeqFormHandler().formMethodDataSourceCreate();
}
}

in init method

public void init()
{

FormBParams formBParams;
Array items;
int i;
;
super();
// Check for passed arguments
if( element.args() )
{
if( element.args().parmObject() )
{
formBParams = element.args().parmObject();
items = formBParams.parmItems();

for( i=1; i<=items.lastIndex(); i++ )
{
DS_Invoice.text(items.value(i));

}
// someDate.dateValue( formBParams.parmSomeDate() );
// someTime.value( formBParams.parmSomeTime() );
}
}

super();
}

note : FormBParams is class that has two accessors just to carry data in Array and get it

if you have another solution better without Args() please send to me because i received errors in this ,many thanks

About Q1:

Weak typing:

object caller = element.args().caller();
if if (SysDictClass::is(caller, classNum(FormRun)) && formHasMethod(caller, identifierStr(doResearch))) // some basic checks
{
caller.doResearch(); // this calls a method defined on the caller form
}

Strong typing:

MyClass myClass;
if (SysDictClass::is(args.caller(), classNum(MyClass)) // this expects that you provided some class as the caller
{
myClass = caller;
myClass.doFormResearch();
}

BTW AX2012 contains “is” operator…

Dear ,

Good , i will try it but i think in the past i write very easy way to do that , do you know another solution ?,regards.

Dear ,

I think you do not understand me . where is the form name ?,simply

i f iam in purchTable form and need to use method in purchline form for example(checkpuch) , how i can do that? regards.

That answer is simple: Don’t do that under any circumstances. Move the code to a class (or a table, if more appropriate).

Well , where do you determine the name of form? which i wanna access its method ,appropriated :slight_smile:

Well , where do you determine the name of form? which i wanna access its method give me example ,appropriated :slight_smile: