passing datasource record from form to menuitem class in ax 2012

Hi All,

I want to pass the current record from from to its menuitem button action class. How this can be achieved. Please suggest an answer in ax 2012

Thanks in advance,

Gopinath

void clicked()
{
    ImportExcel _import=new ImportExcel();
   ;
   _import.importExcel(ItemPriceSimulated.VersionId);
   info('Imported Completed. Check log file for error');
}

Declare your class and pass the field value to ur class method as args like above and in class get the arguments

void importExcel(CostingVersionId _ver)
{
CostingVersionId _version = _ver;

}

In the Class Main method use arg.Record. Make sure u define the datasource for MenuitemButton in from level.

server static void main(Args args)
{
TableName tableName;
;

tableName = args.record();

}

Hi Gopi,

may be bellow code help full for you.

public static void main(Args _args)
{
FormRun caller;
FormStringControl fcsAllocationId;
FormDateControl fdsFrmDate, fdsToDate;
FormDataSource formDataSource;
AllocationId allocationId;
date fromDate, toDate;

AllocationUpload upload = new AllocationUpload();

caller = _args.caller();

fdsFrmDate = caller.control(caller.controlId(“Allocation_FromDate”));
fromDate = fdsFrmDate.dateValue();

fdsToDate = caller.control(caller.controlId(“Allocation_ToDate”));
toDate = fdsToDate.dateValue();

fcsAllocationId = caller.control(caller.controlId(“Allocation_AllocationId”));
allocationId = fcsAllocationId.text();

upload.loadingTimesheetData(fromDate, toDate, allocationId);

formDataSource = _args.record().dataSource();
formDataSource.research(true);
}