Use the Code in Modified Method Of Enum Field Control:
Here HcmEmploymentType is enum and personnelNumber is inbound control for showing the numberSequence in form.
public boolean modified()
{
boolean ret;
HcmEmploymentType hcmEmploymentType;
NumberSeq numberSeq;
SysLastValue nextNumSeq;
SysLastValue nextPersonnelActionNumSeq;
ret = super();
if(HcmEmploymentType::Employee == str2enum(hcmEmploymentType,RelationType.valueStr()))
{
if(lastNumber && numberSeqTablePersonnelNum.RecId && numberSeqPersonnelNum)
{
numberSeqPersonnelNum.abort();
lastNumber = '';
}
numberSeqReferencePersonnelNum = NumberSeqReference::findReference(extendedTypeNum(HcmPersonnelNumberId));
numberSeqTablePersonnelNum = NumberSequenceTable::find(numberSeqReferencePersonnelNum.NumberSequenceId);
if (numberSeqTablePersonnelNum)
{
//generate worker personnel number if number sequence code is created.
numberSeqPersonnelNum = NumberSeq::newGetNumFromId(numberSeqTablePersonnelNum.RecId,
true,
true,
nextNumSeq,
true);
if(numberSeqPersonnelNum)
{
[lastNumber] = nextNumSeq.Value;
personnelNumber.text(lastNumber);
}
}
}
else if(HcmEmploymentType::Contractor == str2enum(hcmEmploymentType,RelationType.valueStr()))
{
if(lastNumber && numberSeqTablePersonnelNum.RecId && numberSeqPersonnelNum)
{
numberSeqPersonnelNum.abort();
lastNumber = '';
}
numberSeqReferencePersonnelNum = NumberSeqReference::findReference(extendedTypeNum(NumberSeqContractor));
numberSeqTablePersonnelNum = NumberSequenceTable::find(numberSeqReferencePersonnelNum.NumberSequenceId);
if (numberSeqTablePersonnelNum)
{
// generate worker personnel number if number sequence code is created.
numberSeqPersonnelNum = NumberSeq::newGetNumFromId(numberSeqTablePersonnelNum.RecId,
true,
true,
nextNumSeq,
true);
if(numberSeqPersonnelNum)
{
[lastNumber] = nextNumSeq.Value;
personnelNumber.text(lastNumber);
}
//personnelNumber.allowEdit(numberSeqTablePersonnelNum.numAllowEdit());
}
}
return ret;
}
Here HcmEmploymentType is enum and personnelNumber is inbound control for showing the numberSequence in form.
public boolean modified()
{
boolean ret;
HcmEmploymentType hcmEmploymentType;
NumberSeq numberSeq;
SysLastValue nextNumSeq;
SysLastValue nextPersonnelActionNumSeq;
ret = super();
if(HcmEmploymentType::Employee == str2enum(hcmEmploymentType,RelationType.valueStr()))
{
if(lastNumber && numberSeqTablePersonnelNum.RecId && numberSeqPersonnelNum)
{
numberSeqPersonnelNum.abort();
lastNumber = '';
}
numberSeqReferencePersonnelNum = NumberSeqReference::findReference(extendedTypeNum(HcmPersonnelNumberId));
numberSeqTablePersonnelNum = NumberSequenceTable::find(numberSeqReferencePersonnelNum.NumberSequenceId);
if (numberSeqTablePersonnelNum)
{
//generate worker personnel number if number sequence code is created.
numberSeqPersonnelNum = NumberSeq::newGetNumFromId(numberSeqTablePersonnelNum.RecId,
true,
true,
nextNumSeq,
true);
if(numberSeqPersonnelNum)
{
[lastNumber] = nextNumSeq.Value;
personnelNumber.text(lastNumber);
}
}
}
else if(HcmEmploymentType::Contractor == str2enum(hcmEmploymentType,RelationType.valueStr()))
{
if(lastNumber && numberSeqTablePersonnelNum.RecId && numberSeqPersonnelNum)
{
numberSeqPersonnelNum.abort();
lastNumber = '';
}
numberSeqReferencePersonnelNum = NumberSeqReference::findReference(extendedTypeNum(NumberSeqContractor));
numberSeqTablePersonnelNum = NumberSequenceTable::find(numberSeqReferencePersonnelNum.NumberSequenceId);
if (numberSeqTablePersonnelNum)
{
// generate worker personnel number if number sequence code is created.
numberSeqPersonnelNum = NumberSeq::newGetNumFromId(numberSeqTablePersonnelNum.RecId,
true,
true,
nextNumSeq,
true);
if(numberSeqPersonnelNum)
{
[lastNumber] = nextNumSeq.Value;
personnelNumber.text(lastNumber);
}
//personnelNumber.allowEdit(numberSeqTablePersonnelNum.numAllowEdit());
}
}
return ret;
}
This is one awesome article post. Thanks Again. Want more.
ReplyDeletehttps://www.efinancialmodels.com/about/