2 Aralık 2011 Cuma

AXAPTA Create new record at another form and return from

Sometimes you can want to or have to create new record  at another form. There are some Axapta forms do it with complex ways. I couldn't understand Axapta's ways.
This is mine simple way:

Main forms data source create method:


public void create(boolean _append = false)
{
    Args                args;
    FormRun             formCreate;
    ;

        args = new Args();
        args.name(formstr(B_ExpressServiceNew));
        args.caller(element);
        formCreate = classfactory.formRunClass(args);
        formCreate.init();
        formCreate.run();
        formCreate.wait();
}

B_ExpressServiceNew, is my new record forms name.
This part should write at new record forms new record method:


    if (element.args() && element.args().caller() && element.args().caller().name() == formstr(B_ExpressService))

    {
     mainForm = element.args().caller();
     mainForm.SetRecord(oTable);
    }


B_ExpressService is my main form, oTable is my new record.
Setrecord method at main form for locate new record:

void SetRecord(SMAServiceOrderTable _order)
{
    ;
    SMAServiceOrderTable.reread();
    SMAServiceOrderTable.data(_order);
    SMAServiceOrderTable_DS.setCurrent();

} 

Hiç yorum yok:

Yorum Gönder