I got a requirement in order to create Multiple number sequence based on type for newly created purchase order in D365FO.
The similar requirement is already exists in fixed assets. Same way I followed here.
1. I created new table with 3 fields.
- Purch type.
- Description.
- Number sequence code.(Organization module --> Number sequences(form) --> Number sequence code(field)).
Purch table method:
[ExtensionOf(tableStr(PurchTable))] final class PurchTable_Extension { public NumberSeq initPONumberSeq(PurchaseType _purchaseType = " ") { NumberSeq purchaseOrderNumberSeq = PurchaseTypeTable::getNumberSeqForType( _purchaseType ? _purchaseType : this.PurchaseType); return purchaseOrderNumberSeq; } }
PurchaseTypeTable(My table) method:
public class PurchaseTypeTable extends common { public static NumberSeq getNumberSeqForType(PurchaseType _purchaseType) { PurchaseTypeTable purchaseTypeTable = PurchaseTypeTable::find(_purchaseType); NumberSeq purchaseOrderSeq; PurchTable purchTable; if (purchaseTypeTable.AutoNumberSequenceTable) { purchaseOrderSeq = NumberSeq::newGetNumFromId(purchaseTypeTable.AutoNumberSequenceTable, true); } return purchaseOrderSeq; } }
Form close method:
[ExtensionOf(formStr(PurchCreateOrder))] final class PurchCreateOrderForm_Extension { public numberseq purchaseordernumberseq; public PurchId purchId; public void close() { if (!purchtable.recid && purchaseordernumberseq) { purchaseordernumberseq.abort(); } } }
Form data source write method:
Keep daxing!!
No comments:
Post a Comment