Create Number Sequence on Sales Module, custInvoiceJour

read more on
http://swathidynamicsax.blogspot.com/2012/07/simple-steps-to-create-number-sequence.html

My case is to create number sequence on Sales Module,
so i had to modify some code on there..

on table SalesParameters.

static client server NumberSequenceReference AI_numRefPackingListId()
{
    return NumberSeqReference::findReference(extendedTypeNum(AI_PackingListId));
}

add this code to class NumSeqModuleSalesOrder\LoadModule

//AIFD_ seq packingListId
datatype.parmDatatypeId(extendedTypeNum(AI_packingListId));
datatype.parmReferenceHelp(literalStr("Packing List Id setiap create Invoice"));
datatype.parmReferenceLabel(literalStr("Packing List Id"));
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmWizardHighest(999999);
datatype.parmSortField(66);
datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
this.create(datatype);
//END

and modify the code on job

static void AIFD_JobSequence(Args _args)
{
   NumberSeqModuleSalesOrder NumberSeqModuleSalesOrderLoc = new NumberSeqModuleSalesOrder();
   NumberSeqModuleSalesOrderLoc.load();
}

then run wizard number sequence and run this job

static void AIFD_TestRunSeqNum(Args _args)
{
   NumberSeq numberSeq;
   AI_PackingListId num;
   ;
   numberSeq = NumberSeq::newGetNum(SalesParameters::AI_numRefPackingListId());
   num = numberSeq.num();
   info(num);
}

done.. voila, i need to add my newly added number sequence to my customize CustInvoiceJour,
so when sales Invoice is created, my newly added number sequence is generated and automatically save in table CustInvoiceJour..

how i did this :

1. add new field on custInvoiceJour, i named it AI_PackingListId and set the extended data type to my new data type.

2. modify some code on class SalesInvoiceJournalCreateBase\initJournalHeader

NumberSeq numberSeqLoc;
AI_PackingListId numPackingListId;

numberSeqLoc = NumberSeq::newGetNum(SalesParameters::AI_numRefPackingListId());
numPackingListId = numberSeqLoc.num();

//add this code below custInvoiceJour.initFromSalesParmTable(salesParmTable);
custInvoiceJour.AI_PackingListId = numPackingListId;
//END

3. Last, Generate Incremental CIL , dont forget that 🙂
Voila.. done !!

happy Daxing !!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s