miercuri, 3 decembrie 2008

Number sequence framework

Number sequence framework

This topic describes how to implement the number sequence framework for a new module ("MyModule") in Axapta. Some of the steps below might be irrelevant, if they have been previously carried out for other purposes in your new Axapta module.

  • Create a parameter table for the new module: MyModuleParameters.
    This table must follow the standard Axapta design for parameter tables. This means that the table must, as a minimum, contain a Key field, and the standard method: Find. Furthermore, some standard methods must be overloaded (delete and update). These can be copied from one of the other parameter tables.
  • Create an enumerated value for the number sequence value.

NOTE

  • Configuration keys are used to detect the active number sequence references in your Axapta installation. If the configuration key is not enabled, the modules number sequence references are not displayed in the general References form. This means that the user cannot see references from modules that are not enabled.

 
 

  • Implement static methods.
    MyModuleParameters::numberSeqModule()
    Reference the enumerated value in the number sequence module enumerator here.

    MyModuleParameters::numberSeqReference()
    Copy these from one of the other parameter tables, and change the names.
  • Add line in method.
    Add MyModuleParameters::Find() in method Company.selectParameters().
  • Create a form to display the new parameter table.
    It's important that the functionality of number sequence references is copied exactly from one of the other parameter forms (e.g., copy methods, query, properties, etc.) Remember to correct names of the called methods.
  • Create new class.
    NumberSeqReference_MyModule and let this class extend class: NumberSeqReference.
  • Add line in method. NumberSeqReference::Construct()
    Copy one of the existing lines, and change the feature key and class name.
  • Add line in method. NumberSeqReference.loadAll()
    Copy one of the existing lines, and change the name of the parameter table.

Your framework is now established. When you run your new parameter form, you should not get any errors. On the Number sequence tab page, you should get the message: "No setup required".

To make number sequence references for your new module, you must:

  • Overload the method:
    NumberSeqReference.loadModule()
     
  • Create new method:
    NumberSeqReference_MyModule.loadModule()
    In this new method, specify each reference needed in your new module.

Please refer to the written documentation in method NumberSeqReference.loadModule() for details on how to create a reference.

After creating your references, the system will automatically detect them when opening the parameter form. This is now visible in the grid on the Numbersequence tab page.

How to refer to your new references

For each reference specified in NumberSeqReference_MyModule.loadModule(), you must create a static method on your parameter table. Assuming you have specified a reference for the datatype: MyDataType, you need to create the method: MyModuleParameters::numRefMyDataType().

Copy a "numRef" method from one of the other parameter tables, and change the names of the method to numRefMyDataType, and the referenced data type to MyDataType.

You are now ready to refer to the reference from the X++ code, for example:

MyNewId = NumberSeq::newGetNum(MyModuleParameters::numRefMyDataType()).

Niciun comentariu: