Sunday, 20 March 2011

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

}

No comments:

Post a Comment