29 April 2014

Refresh the Form Data from another Form in AX 2009/ 2012

HI Folks,

Hope this will help you..In the following scenario we have to insert records in CustGroup from the child form.
As shown below. Can be achieve by using FormDataSource or FormObjectSet classes.

Note: formDataSource = element.args().record().dataSource(); // _object = element.args().record().dataSource();

Step 1 create a button in cust goup form

Step 2 In this button write the below code where you are calling a form and passing the record.


void clicked()
{
Args args;
FormRun formRun;

super();

args = new args("CustGroupCreate");
formRun = new FormRun(args);
args.record(CustGroup);

formRun.init();
formRun.run();
formRun.wait();
}

Step 3 Create new form called "CustGroupCreate" as shown below with unbounded controls.


Step 4 Declare a variable for FormDataSource class in as shown below :

public class FormRun extends ObjectRun
{
FormDataSource formDataSource; // FormObjectset _object;
CustGroup localCustGroup;

}
Step 5 Override a init() method and write the below code to get the parent form datasource.

public void init()
{
super();
if(element.args().record())
formDataSource = element.args().record().dataSource(); // _object = element.args().record().dataSource();
}

Step 6 Take another override method close()and code for insertion and using the formDataSource variable refresh the parent Data Source as shown below. Once you you insert a record and close the form that will refresh the parent Data source immediately.

public void close()
{
super();

localCustGroup.CustGroup = CustGroup_CustGroup.text();
localCustGroup.Name = CustGroup_Name.text();
localCustGroup.PaymTermId = CustGroup_PaymTermId.text();
localCustGroup.insert();

formDataSource.research(true); // _object.research(true);
}

1 comment:

  1. thanks for given information we are providing microsoft dynamics online training with real time faculty if any one interest to learn microsoft dynamics ax view here

    ReplyDelete

Give me the commetns and solutions

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...