Tuesday 20 December 2011

Easy steps to use number sequence and number sequence form handler in ax 2009

Hi Friends,
Today we are going to learn about Number sequence generation through easy steps... Note that these steps did not have naming conventions and use this as per your convenience,
NOTE: Please bear with me in this tutorial; I am going to break naming convention best practices, so that my example is clearer.
The first thing you need to do is determine which module you want/need to create the new number sequence for. For this example, I am going create a new number sequence for the “Accounts Receivable” module. Then take the following steps:
Creating a new Number Sequence for the Accounts Receivable Module
1. Create your Extended Data Type that will be used in your table as your Number Sequence field. For this example we will create a string based Extended Data Type called edt_ComplaintId (with a Label property = “Complaint Report”)
2. Next, since we are using the “Accounts Receivable” module, we must modify the proper NumberSeqReference_XXXX Class. Accounts Receivable, actually maps to Customer (or Cust), so we need to make a modification to the NumberSeqReference_Customer class.
We are only concerned with the loadModule() method, and will simply need to add the following code to it:
numRef.dataTypeId = typeId2ExtendedTypeId(typeid(edt_ComplaintId)); numRef.referenceHelp = "Unique key for the Complaint Report"; numRef.wizardContinuous = true;
numRef.wizardManual = NoYes::No;
numRef.wizardAllowChangeDown = NoYes::No;
numRef.wizardAllowChangeUp = NoYes::No;
numRef.wizardHighest = 999999;
3. After compiling and saving your changes, the next step is to use the Number Sequence Wizard to set it up. Click Basic > Setup > Number sequences > Number sequences to open the form where you can manage your Number Sequences.
4. Click on the “Wizard” button, which then should initialize the wizard.
NOTE: If you receive an error at this point telling you “The application already has the required number sequences”, this means that you either did not add the definition to an established NumberSeqReference_XXXX Class' (in this example, the NumberSeqReference_Customer Class) loadModule() method, or you have already run the Wizard and set it up.
5. Once you arrive on the Wizard Welcome screen, click the Next > button.
6. On the following screen, verify that the Module is “Accounts receivable” and the Reference is “Complaint Report” (which is the label of our Extended Data Type). The Number Sequence code is just an auto-generated value that you can leave as is (Remember this code, so that you can find it in your list of Number Sequences, because you are going to want to make a couple changes to it). Once you have verified the above, click the Next > button.
7. The next screen just gives you an overview, click the Finish button.
8. You should then see your Number Sequence in the list.
9. You will probably want to change the Format to something such as “CR-######”
10. At this point, your Number Sequence is ready for use!
Using the Number Sequence
1. Create a Table and name it tbl_Complaint.
2. Add the edt_ComplaintId Extended Data Type as one of the fields (drag and drop the Extended Data Type directly into the fields of the Table) and name this field ComplaintId.
3. Add the following Method to the tbl_Complaint:
static client server NumberSequenceReference numRefComplaintId()
return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(edt_ComplaintId)));
4. Create a Form called frm_Complaint.
5. Add the tbl_Complaint table to the form’s Data Sources, and name the Data Source ds_Complaint.
6. Add the following Methods to the Form:
public class FormRun extends ObjectRun
NumberSeqFormHandler numberSeqFormHandler;
NumberSeqFormHandler numberSeqFormHandler()
if (!numberSeqFormHandler)
numberSeqFormHandler = NumberSeqFormHandler::newForm(Tmt_CallReport::numRefComplaintId().NumberSequence, element, ds_Complaint.dataSource(), fieldnum(tbl_Complaint, ComplaintId));
return numberSeqFormHandler;
7. Add the following Methods to the ds_Complaint Data Source:
public void create(boolean _append = false)
public void delete()
public void write()
Vivek Chirumamilla.

1 comment:

  1. how to create the number sequence based on the selected group using numbersequence form handler.