Number sequences on the form [NumberSeqFormHandler] in Dynamics AX [X++]

Friends, Today let us learn how to use number sequences on the form.
[Note: It is assumed that all number sequences have been created and available to use in the system]

To use a number sequence for a form in Microsoft Dynamics AX, follow these steps.
1. In the classDeclaration method of the form that will be accessing data, add a variable declaration for the number sequence handler. The following example shows the variable definition for a number sequence handler.

public class FormRun extends ObjectRun
{
NumberSeqFormHandler numberSeqFormHandler;
}

Add the NumberSeqFormHandler method to the form. The code in this method will create an instance of the number sequence form handler and return it. The following example shows the code that returns the number sequence form handler for the customer account number in Accounts Receivable module.

NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler = numberSeqFormHandler::newForm(CustParameters::numRefCustAccount().NumberSequence,
element,
CustTable_DS,
fieldNum(CustTable, AccountNum)
);
}
return numberSeqFormHandler;
}

3. Add create, delete, validatewrite, write,linkactive methods to the data source of the table that contains the field for which the number sequence is being used.

_____________________________________________________________

public void create(boolean _append = false)
{
element.numberSeqFormHandler().formMethodDataSourceCreatePre();
super(_append);
element.numberSeqFormHandler().formMethodDataSourceCreate();
}
_____________________________________________________________

public void delete()
{
element.numberSeqFormHandler().formMethodDataSourceDelete();
super();
}
_____________________________________________________________

public boolean validateWrite()
{
boolean ret;
ret = super();
ret = element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret) && ret;
return ret;
}
_____________________________________________________________
public void write()
{
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
}

_____________________________________________________________
public void linkActive()
{
element.numberSeqFormHandler().formMethodDataSourceLinkActive();
super();
}
_____________________________________________________________
4. Override the close method on the form and add the below code

void close()
{
;
if (numberSeqFormHandler)
numberSeqFormHandler.formMethodClose();
super();
}

Advertisements

One Response to “Number sequences on the form [NumberSeqFormHandler] in Dynamics AX [X++]”

  1. best dj software Says:

    best dj software…

    […]Number sequences on the form [NumberSeqFormHandler] in Dynamics AX [X++] « Sreenath Reddy G – Dynamics AX Consultant's Blog[…]…


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: