My table is SMAParameters (It can find from modules parameters screen, setup tab). Add this method to table:
public server static NumberSequenceReference numRefRMARequestNo()
{
return NumberSeqReference::findReference(
typeid2extendedtypeid(typeid(B_RMARequestNo)));
}
Update for AX 2012:
Instead of
typeid2extendedtypeid(typeid(B_RMARequestNo))
write
extendedTypeNum(SNBmasterNum)
"B_RMARequestNo" at here is our tables key field's extended data type.
After that we have to go number sequence class. Related class name can be find from parameter table's numberSeqModule method. Write this code part at loadModule method:
/* RMA Request No */
numRef.DataTypeId = typeId2ExtendedTypeId(typeid(B_RMARequestNo));
numRef.ConfigurationKeyId = configurationkeynum(SMAManagement);
numRef.ReferenceHelp = literalstr("My Number Seq...");
numRef.WizardContinuous = false;
numRef.WizardFetchAheadQty = 20;
numRef.WizardManual = NoYes::No;
numRef.WizardAllowChangeDown = NoYes::No;
numRef.WizardAllowChangeUp = NoYes::No;
numRef.SortField = 11;
this.create(numRef);
Put upper numberseqs sortfield value +1 to Sortfield field.
Update for AX 2012:
Before launch wizard run this command
NumberSeqApplicationModule::loadAll();
Then Basic->Setup->Number sequences->Number sequences. Run Wizard.
Look service parameters->number sequence tab at related modules menu for check.
Now we can use this number sequence at forms...
Add this line at forms classDeclaration method:
NumberSeqFormHandler numberSeqFormHandler;
Add this method to form:
{
;
if (!numberSeqFormHandler)
{
numberSeqFormHandler = NumberSeqFormHandler::newForm(SMAParameters::numRefRMARequestNo().NumberSequence,
element,
B_RMARequestTable_DS,
fieldnum(B_RMARequestTable,RequestNo));
}
return numberSeqFormHandler;
}
Update: Upper line should be like below for AX 2012:
numRefRMARequestNo().NumberSequenceId
instead of
numRefRMARequestNo().NumberSequence
B_RMARequestTable_DS is my tables datasource. RequestNo is key field.
Form close method:
{
if (numberSeqFormHandler)
{
numberSeqFormHandler.formMethodClose();
}
super();
}
Data source methods:
{
;
element.numberSeqFormHandler().formMethodDataSourceLinkActive();
super();
}
{
boolean ret;
ret = super();
ret = element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret) && ret;
return ret;
}
{
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
}
public void delete()
{
ttsbegin;
element.numberSeqFormHandler().formMethodDataSourceDelete();
super();
ttscommit;
}
{
ttsbegin;
element.numberSeqFormHandler().formMethodDataSourceDelete();
super();
ttscommit;
}
{
element.numberSeqFormHandler().formMethodDataSourceCreatePre();
super(_append);
if (!extern)
{
element.numberSeqFormHandler().formMethodDataSourceCreate();
}
}
That's all..
Hiç yorum yok:
Yorum Gönder