Search This Blog

Friday, 11 October 2013

Generating Multiple Number Sequence in AX 2009



Step1:

Create a table NumSeq table , add two fields NumSeqcode and Description . Enter two or more records in that table


Step 2:

Add one new field called VendNumSeq in VendParameters Table .
Add VendNumSeq in VendParameters Form.  write lookup method for VendNumSeq field to display the NumSeqcode and Description from NumSeq Table  or give Edt level relationship .

public void lookup()

{
    Query                 query = new Query();
    QueryBuildDataSource  qbds;
    QueryBuildRange       queryBuildRange;
    SysTableLookup        sysTableLookup;

    ;
    sysTableLookup  =   SysTableLookup::newParameters(tablenum(NumSeq),this);
    sysTableLookup.addLookupfield(fieldnum(NumSeq,NumSeqcode));
 sysTableLookup.addLookupfield(fieldnum(NumSeq,Description));
    sysTableLookup.performFormLookup();


}


Step 3:

In VendNumSeq field override modified method


public boolean modified()
{
    boolean ret;
    str st;
    VendParameters  vendParametersLoc;
    NumberSequenceReference  numberSequenceLocal;
;
    ret = super();

    vendParametersLoc = VendParameters::find();
    NumberSequenceLocal = NumberSequenceReference::find1();
    st = NumberSequenceReference.referenceLabel();

    ttsbegin;
    select firstonly forupdate NumberSequence from numberSequenceLocal;

    {

        st = "Vend account";
        NumberSequenceReference.NumberSequence=this.valueStr();
        NumberSequenceReference.update();

    }
    ttscommit;

    return ret;
}

Step 4 :

Generate NumberSequence for the records present in NumSeq Table

Basics-> Setups->Number Sequence -> Number Sequence


Create new record for INDV,UKV,etc (according to your requirements)

Step 5:

 Check whether updates are made in Vendor Account field in NumberSequenceTab in VendParameters Form


Step 6:

Accounts Payable -> Common Forms-> Vendor Details
Press ctrl +N , Number sequence will be generated according to the input given in VendSeqNum field present in VendParameters  Form (Accounts Payable->Set ups-> Parameters-> General ->VendSeqNum )







No comments:

Post a Comment