Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Tuesday, July 9, 2013

Number Sequence in Dynamic AX (for Form level)

1. Create EDT
2. Use that EDT in the Table where it is required
3. Select the Class module which you going to implement this Number seq.
//Consider if we want for HRM then “NumberSeqModuleHRM” class is the target.
//Add below code in the loadModule()
            protected void loadModule()
     {
     NumberSeqDatatype datatype = NumberSeqDatatype::construct();
//Added by Alfasith
     datatype.parmDatatypeId(extendedtypenum(customerID));
//your EDT
     datatype.parmReferenceLabel(literalstr("RES-customerID"));
//Your label
     datatype.parmReferenceHelp(literalstr("RES-customerID"));
     datatype.parmWizardIsContinuous(true);
     datatype.parmWizardIsManual(NoYes::No);
     datatype.parmWizardIsChangeDownAllowed(NoYes::No);
     datatype.parmWizardIsChangeUpAllowed(NoYes::No);
     datatype.parmWizardLowest(1);
     datatype.parmWizardHighest(99999999);
     datatype.parmSortField(15);
//(This 15 is the next number that already in that default list)
     datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
    this.create(datatype);
    //code end
     }

4. Select the concern table. Create new methods as below
Here we take HRMParameters table 
// table on which that number seq is going to generate.

static client server NumberSequenceReference customer()
{
    return NumberSeqReference::findReference(extendedtypenum(customerID));//Your EDT name
}

5. Create a new job with the following code and run it:

static void NumberSeqLoadAll(Args _args)
{
NumberSeqApplicationModule::loadAll();
}

6. ( Control + W )
Select Organization administration-> Number Sequence-> Number Sequence
Select the module //here we select Human Resources
Select the EDT you created //Surly that EDT you created will be appear here.
Click GENERATE

7. Create a new job with the following code and run it:
static void NetvendNumberSeq(Args _args)
{
    NumberSeq  numberSeq;
    StudentID num;
    ;
    numberSeq = NumberSeq::newGetNum(VendParameters::student());
   
    num = numberSeq.num();
    info(num);
}

8. Select the Form on which that table is required.
Drop the table in to that form Data Source.

8(a). ClassDeclaration. Write the below code.

public class FormRun extends ObjectRun
{
    NumberSeqFormHandler numberSeqFormHandler;
}
/*************************************************************/
8(b). Create new method

NumberSeqFormHandler numberSeqFormHandler()
{
    if (!numberSeqFormHandler)
    {
       numberSeqFormHandler = NumberSeqFormHandler::newForm(NetRMSParameters::customer().NumberSequenceId,
                                                             element,
                                                             Table2_ds,
                                                             fieldNum(Table2, customerID)
                                                            );
    }
    return numberSeqFormHandler;
}

/***********************************************************/
8(c). Override the datasource methods of that table with following method in that form.
public void delete()
{
    ;
    element.numberSeqFormHandler().formMethodDataSourceDelete();
     super();
}
/***********************************************************/
public void write()
{
    super();
    element.numberSeqFormHandler().formMethodDataSourceWrite();
}
/***********************************************************/
public void create(boolean _append = false)
{
    ;
    super(_append);
    element.numberSeqFormHandler().formMethodDataSourceCreate();
}

/***********************************************************/

1 comment:

  1. Thanks for providing the solution..Found it useful Mohamed...

    ReplyDelete

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...