Hi Folks,
I have generated a continuous number sequence for my custom EDT "XXX" through code. Everything works fine. But I wanna know is there any way we could get the previously generated number sequence if it's not written to database.
Scenario:
Step 1: Created a new record in my form which generates a number sequence XXX0001 for my custom EDT and saved the record
Step 2: On creating another new record and this time a number sequence of XXX0002 gets generated but this time "Cancel" button is clicked and XXX0002 is not written to the database as records doesn't save the record.
Step 3: After creating new record, now the system generates the number sequence XXX0003 even though XXX0002 is unused for my record.
Goal: I want to find a way to generate XXX0002 in third step instead of XXX0003.
Can anyone please suggest? Appreciate your time.
can you see your topic of question?but why your answer have no connection with your question?
Hi d365fo-avatar,
I'm getting a bit confused. You started the question with a custom EDT, but now you are asking about the ProjTable?
I haven't checked all the coding related to number sequences on the ProjTable. Not sure if it is supported by Microsoft to put the number from a deleted project back in the status list. There is some actual coding for taking care of this on ledger journal lines. When you delete a journal line, it will create a record for that number in the status list.
Thanks Andre,
I have took the help of AssetTable form and tried to do the same way. It worked on three methods first on Modified method, write() of datasource and used closed() of form.
But here, I tried to re -use the number sequence after the project is deleted.
I thought to use the delete() of ProjTable, but than I realized that in ProjTable, I'll not be able to use the number sequence buffer.
So could you please confirm, can I do this while deletion of Project.
Hi D365FO Avatar,
The "numberSeq.used();" statement should not be used in the init() method. You must implement this on the closeOK() method.
Hi Andre,
I have implemented as you suggested in below code, but still it is not working as in abort() method it is going under first condition where active variable is false.
[ExtensionOf(formstr(XXX))] final class XXXFrm_Extension { public NumberSeq numberSeq; Public XXX projIdnew; void init() { if (! numberSeq) { ttsbegin; numberSeq = NumberSeq::newGetNum(NumberSequenceReference::findByDatatypeAndScope(extendedTypeNum(XXX)), true); ProjIdnew = numberSeq.num(); numberSeq.used(); ttscommit; } next init(); } ////// /// public void closeCancel() { ttsbegin; if (numberSeq) { numberSeq.abort(); } next closeCancel(); ttscommit; } }
Hi D365FO Avatar,
You need to use the functions available on the NumberSeq class.
When retrieving a new number, you can set a parameter for _makeDecisionLater to true.
At that moment, when retrieving the number sequence on your form it will add the new number to the number sequence status list.
When a user will save the record, then call the method 'used()'. When he cancels, then call the method 'abort()'.
The method 'used()' will delete the record in the status list. The 'abort()' function will keep the record but will set it with a status free.
When there is a free number in the status list, it will pick that number before getting a new number from the Next field on the number sequence. Also have a look at standard coding using these methods.
André Arnaud de Cal...
292,031
Super User 2025 Season 1
Martin Dráb
230,868
Most Valuable Professional
nmaenpaa
101,156