Hi Sohaib,
Here is the step By Step Procedure of the Asset Id Number sequence based on the Asset group
1. I am Already Debug the Code , First They are write the Code in the update design of the asset table form.
NumberSequenceTable numberSequence;
AssetGroup assetGroup;
;
// Enable/disable fields
assetNum1.allowEdit(assetTable.allowEditOfAssetNum());
assetGroup = assetTable.assetGroup();
if (assetGroup)
{
numberSequence = NumberSequenceTable::find(assetTable.assetGroup().AutoNumberSequenceTable);
}
if (!numberSequence)
{
numberSequence = Assetparameters::numRefAssetId().numberSequenceTable();
}
if (assetGroup
&& numberSequence
&& numberSequence.Continuous
&& !numberSequence.AllowChangeDown
&& !numberSequence.AllowChangeUp)
{
identification_AssetId.allowEdit(false);
}
else
{
identification_AssetId.allowEdit(true);
}
when we are open the asset table form first the debugger is enable in this method update design and in this method if asset group is not there it is take the EDT number sequence
numberSequence = Assetparameters::numRefAssetId().numberSequenceTable();
then next time we are give the Asset Group in the Front end Form It is take the Asset Group Number sequence.
if (assetGroup)
{
numberSequence = NumberSequenceTable::find(assetTable.assetGroup().AutoNumberSequenceTable);
}
In this Code they are write The Code in the Asset table assetGroup() Method, It is Take the Asset Group based on the Asset Id Asset Group and in the Asset Group Table we are Given the Auto Number Sequence Table Field and Give the Number Sequence.
Some of the Methods in the Asset Table to edit the Auto Number Sequence and
public boolean allowEditOfAssetNum()
{
NoYes allowEdit;
;
allowEdit = (AssetParameters::find().AutoNumber == NoYes::No);
if (allowEdit)
{
allowEdit = (this.assetGroup().AutoNumber == NoYes::No);
}
return allowEdit;
}
One Method Called initialize the Number Sequence
public server NumberSeq initAssetNumberSeq(AssetGroupId _assetGroupId = '')
{
AssetParameters assetParameters = AssetParameters::find();
AssetGroup assetGroup = AssetGroup::find(_assetGroupId ? _assetGroupId : this.AssetGroup);
NumberSeq assetNumberSeq;
;
if (assetGroup.AutoNumber && assetGroup.AutoNumberSequenceTable)
{
assetNumberSeq = NumberSeq::newGetNumFromId(assetGroup.AutoNumberSequenceTable, true);
}
if (!assetNumberSeq && assetParameters.AutoNumber)
{
assetNumberSeq = NumberSeq::newGetNum(AssetParameters::numRefAssetId(),true);
}
return assetNumberSeq;
}
In Validate Write method of the asset Table, They Write the Code Like this
assetGroup = this.assetGroup();
if (ret
&& assetGroup
&& assetGroup.AutoNumber
&& assetGroup.AutoNumberSequenceTable)
{
ret = NumberSeq::numCheckFormat(this.AssetId, NumberSequenceTable::find(assetGroup.AutoNumberSequenceTable));
}
In Form Asset Table ->Data Sources -> Fields ->Asset Group->Modified
void modified()
{
;
super();
if (assetIdNumberSeq)
assetIdNumberSeq.abort();
assetIdNumberSeq = assetTable.initAssetNumberSeq();
if (assetIdNumberSeq)
{
assetTable.AssetId = assetIdNumberSeq.num();
assetIdAllocated = assetTable.AssetId;
}
assetTable.dataSource().refresh();
element.updateDesign();
}
For Every Asset Group they create the Separate Number Sequence and They Assign in the Asset Group Form.
Every time Change the Asset Group It is Take the New Number sequence According to the Asset Group Number Sequence.