blog for Dynamics Axapta

Creating Number Sequence for Existing Module in AX

Suppose you have created a new Form in  Existing Module and want to set up NumberSequences on that form just like the base module from the MODULENAMEParameters Form.


Here is what you do:
Step 1:

Assume you have created a new EDT called AX_myEDT which is the Primary Key in the Form Datasource Table.
 

Step 2:

Append \Classes\NumberSeqReference_MODULENAME\loadModule() method and add the following code at the end

//==========================================
numRef.DataTypeId = typeId2ExtendedTypeId(typeid(AX_myEDT)); // The new EDT you made
numRef.ConfigurationKeyId = configurationkeynum(Your Config Key); // Any Configuration key you made
numRef.ReferenceHelp = literalstr("Your label."); // Label you want to appear on the Parameters Form
numRef.WizardContinuous = true;
numRef.WizardManual = NoYes::No;
numRef.WizardAllowChangeDown = NoYes::No;
numRef.WizardAllowChangeUp = NoYes::No;
numRef.SortField = 12; // Sorting on the Parameters Form
numRef.WizardHighest = 999999;
this.create(numRef);
//==========================================

 

Step 3:
 

Create a new Method in the MODULENAMEParameters table
\Data Dictionary\Tables\
MODULENAMEParameters\Methods\ numRefSomeMethodID

 

 

Add the below methods to the respective form:

 

In Class Declaration :

 

NumberSeqFormHandler    numberSeqFormHandler;

 

——————————————————————————————————————–

 

Create new method:

 

NumberSeqFormHandler numberSeqFormHandler()

{

    if (!numberSeqFormHandler)

    {

        numberSeqFormHandler = NumberSeqFormHandler::newForm(MODULENAMEParameters::numRefVas_NewNumSeq().NumberSequence,

                                                             element,

                                                             datasoruce_DS,

                                                             fieldnum(DataSoruce,Fieldname)

                                                            );

    }

    return numberSeqFormHandler;

}
 
Step 5:
 

Add Create, Write and Delete methods to the Data source in the Form:

 

Create:

 

void create(boolean append = false)

           // If created externally

{

    ;

    element.numberSeqFormHandler().formMethodDataSourceCreatePre();

    super(append);

    element.numberSeqFormHandler().formMethodDataSourceCreate();

}

 

 

Write:

 

void write()

{

 

 

    ttsbegin;

 

    element.numberSeqFormHandler().formMethodDataSourceWrite();

 

    super();

 

    ttscommit;

}

 

Delete:

 

void delete()

{

    ttsbegin;


    element.numberSeqFormHandler().formMethodDataSourceDelete();

 

    super();


    ttscommit;

}

 

Step 6:

 

Run NumberSequence Wizard

 

Basic -> Setup -> NumberSequences -> Number Sequences

 

Create New Number Sequence code and assign the format. Click "Wizard" button and choose your number sequence in the next screen.

 

Now open your form to see the Number Sequence you created.

Advertisements

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: