Is it possible to retrieve the next auto-incremented ID before entity creation?

I need to retrieve the next auto-incremented ID before creating the entity. I need it to populate another field at creation (an invoice reference ex INVOICE-2022-<NEXT_INVOICE_ID>).

Is it possible to do so before creation, or do I need to first create it, and then retrieve it and edit the entity ? (which sounds cumbersome)

Thanks !

if it is a relationship, you should create it before you make the connection to the entity.

If it is just a number, you can always get the last one and add one (because it is auto-incremented). But I do think the correct thing to do is to create it before assigning it.

1 Like

Thanks, I think I’ll do it like that then