Friday, April 17, 2015

Number Sequence

1) we need to create EDT as string KBNumSeqCustGroupNum.
2) we need to add code for the particular module. so we have to choose which module we are going to add number sequence.in this case ,am going to add in customer module.Class--NumberSeqModuleCustomer--LoadModule Method






3) Go to OA-Common-Number Sequence . Click Generate Button



Click the details button below and set or change the value as you like in the number sequence, highest and lowest and format.


Click finish button


Go to the Custgroup table and added KBNumSeqCustGroupNum edt to the field and set the allow edit as NO. add the KBNumSeqCustGroupNum edt to overviewgroup in the table.



open the custgroup form. add the following codes .

  1. Write the following code on the Class declaration node
     NumberSeqFormHandler numberSeqFormHandler;

  2. Create a new method on the form and write the following code
    NumberSeqFormHandler numberSeqFormHandler(){
    if (!numberSeqFormHandler){
    //create a reference of number sequence form handler class specifying the         EDT, Data source name and the field of the table
    numberSeqFormHandler =NumberSeqFormHandler::newForm(NumberSeqReference::findReference(extendedtypenum(KBNumSeqCustGroupNum)).NumberSequenceId, element,CustGroup_DS,fieldnum(CustGroup,KBNumSeqCustGroupNum));}return numberSeqFormHandler;
    }

  3. Override the close method of the form and write the following code
    public void close()
    {
        if (numberSeqFormHandler)
        {
            numberSeqFormHandler.formMethodClose();
        }
        super();
    }

  4. Override the create method on the CustGroup data source and add the following code
    public void create(boolean _append = false){
    element.numberSeqFormHandler().formMethodDataSourceCreatePre();
    super(_append);
    element.numberSeqFormHandler().formMethodDataSourceCreate(true);}

  5. Override the write method on the CustGroup data source and add the following code
    public void write(){
    super();
    element.numberSeqFormHandler().formMethodDataSourceWrite();}

  6. Override the validateWrite method on the CustGroup data source and add the following code
    public boolean validateWrite(){
    boolean ret;
    ret = super();
    ret = element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret) && ret;
    return ret;}

  7. Override the delete method on the CustGroup data source and add the following code
    public
    void delete()
    {
    element.numberSeqFormHandler().formMethodDataSourceDelete();
    super();}

  8. Override the linkActive method on the CustGroup data source and add the following code
    public
    void linkActive()
    {
    element.numberSeqFormHandler().formMethodDataSourceLinkActive();
    super();}
  9.  once we complete the above procedure, just open the custGroup form and click new button automatically number sequence field is added as well as number filled.
http://www.dynamics101.com/2014/09/creating-custom-number-sequences-microsoft-dynamics-ax-2012/

No comments: