UniqueNumbersService in cuba 7.2.6


I’m trying to get the number sequence tho work in cuba with no succes. I checked the forum and google but all the topics and solutions are to old. And the manual is’nt in my opinion very specific about this topic. My code is:

private UniqueNumbersService unService;

protected void initNewItem(GrondRegistratie item) {


Can anyone please point me out in the right direction.



Mmm. I’ve used the UniqueNumberService in Kotlin and it seems to work fine, so I’m not sure why it doesn’t work in your case.

You haven’t said exactly what your’e seeing though. Looking at your code, it’s possible that the number is being generated, but the item property is not being set. I would start by assigning unService.getNextNumber to a variable and run it through the debugger to make sure that’s working.

Hi Ray,

I’m not seeing anything that’s the problem. Is it possible to help me with the exact code? In the manual i haven’t seen a step by step option.



No problem.

    private lateinit var uniqueNumbersService: UniqueNumbersService


    val nextReferenceNumber = uniqueNumbersService.getNextNumber("MANUSCRIPT_REFERENCE")

That’s in Kotlin, but it should be fine in Java as it’s exactly the same code. I’ve tried it with the seed value you used and it works.

The only difference I can see is that you have called it directly inside a screen handler. Mine is called as part of a service. Could you try transferring the code into a service and seeing if that makes a difference?

The manual also mentions a different API, which you could also try, though I’m not sure that does anything different.