'how to generate id field in entity as per our sequence criteria

Bydefault moqui generates 100000 and so on as IDs for entities. i.e 100000,100001,100003... But i want AMG000100000 as start point so that it will contnue as AMG000100001,AMG000100002 and so on. I tried it various ways but nothing is working. Can any one suggest.



Solution 1:[1]

You can set a prefix for primary (single key) sequenced IDs per-entity with the entity.@sequence-primary-prefix attribute and for all entities using the entity-facade.@sequenced-id-prefix attribute. This will not left zero pad the numeric part of the sequence as you show in your examples, there is currently no OOTB support for something like that (you would have to change the framework code, or in your code that creates records augment the value coming back from the framework, or just your own sequencing code).

Solution 2:[2]

you can use the sequence-primary-prefix field on the entity definition to set a prefix, however without the zero padding as David indicated.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David E. Jones
Solution 2 Hans Bakker