Tuesday, 29 March 2011

How can I extract the hour, minute and seconds from AX2009 time?

static void time(Args _args)
{
TimeIn _TimeIn;
int hourInt, minuteInt , SecondInt;
str s;
;

_TimeIn = str2time('5:45');


s = time2str(_TimeIn,0,0);
info(strfmt("%1",s));

hourInt= str2int(substr(s,0,2));
info(strfmt("%1" ,hourInt));
minuteInt= str2int(substr(s,4,2));
info(strfmt("%1" ,minuteInt));
SecondInt= str2int(substr(s,7,2));
info(strfmt("%1" ,SecondInt));

}

Sunday, 27 March 2011

How to get current language of AX2009?

using following code

info( infolog.language());

How to refresh data source Table level method?

object Table1_ds;
;
Table1_ds = Table1.dataSource();

if(Table1_ds )

{
Table1.dataSource().refresh();
}


Sunday, 20 March 2011

How to refresh parent form data Source against child form button clicked

On Parent form data source write a method “refreshDatasource “

Step:1

void refreshDatasource ()

{

;

ParentTable_ds.research(true);

}

Step: 2

On child form click button write following code

Void Clicked

{

element.args().Caller().refreshDatasource();

}

Steps to Create Number Sequence on form using Table Level Methods in Microsoft Dynamics Ax2009

I will describe these steps with example in this example I have two Tables “Table1” and “Parameter Table” OR NumberSequenceReferenceone extend data type “Test” and “form1”.

Step1: Add one field in Table 1

Filed1 using extend data type Test

Write two methods on Table 1

Let suppose name are numberSeqFormHandleFiled1(Parameter1,Parameter2) and

formMethodDataSourceCreate(Parameter1,Parameter2)

Step 2: Write one method on Parameter Table OR NumberSequenceReference

numRefFiled1()

Detail code of all methods

static client server NumberSequenceReference numRefFiled1 ()

{;

return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(Test)));

}

***************************************************************************

public NumberSeqFormHandler numberSeqFormHandleFiled1 (FormRun _element, FormDataSource

_ Table 1_ds)

{

NumberSeqFormHandler numberSeqFormHandlerfiled1;

;

numberSeqFormHandlerfiled1= NumberSeqFormHandler::newForm(ParameterTable::numRefFiled1().NumberSequence,

_element,

_Table 1_ds,

fieldnum(Table1, Field1)

);

return numberSeqFormHandlerfiled1;

}

OR you can replace ParameterTable to NumberSequenceReference

numberSeqFormHandlerfiled1= NumberSeqFormHandler::newForm(NumberSequenceReference::numRefFiled1().NumberSequence,

_element,

_Table 1_ds,

fieldnum(Table1, Field1)

public void formMethodDataSourceCreate(FormRun _element, Object _Table1_ds)

{;

this.numberSeqFormHandlerField1(_element, _Table1_ds).formMethodDataSourceCreate();

}

Step 3: Drag Table1 on form1 as data source

Override “Create “ method of Table1 data source

In create method write following code

public void create(boolean _append = false)

{

;

super(_append);

Table1.formMethodDataSourceCreate(element,Table1_ds);

}