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);
}

25 April 2014

Hi, Friends,

below code will helps to convert the sting to barcode, you just pass the string type and get the barcode



str 128 Convert2Code128(str _str)
{
BarCode barCode1 = BarCode::construct(barCodeType::Code128);
;
barCode1.string(true, strUpr(_str));
barCode1.encode();
return barCode1.barcodeStr();
}


then setup the properties as below:


10 April 2014

UTCDateTime to Date conversion and date comparition

HI Guys,This may be useful for you.

Date _date;

_date = DateTimeUtil::date(testTable.CraetedDateTime); // _time = DateTimeUtil::Time(testTable.CraetedDateTime); to get time

if(_date <= 31\12\2010) // dd\mm\yyyy
// do some thing


Thanks
Sunil

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-...