Numeric sequence with dynamic prefix

How can I implement numeric sequence with dynamic prefix? Let’s say that there is an entity User and each instance of User can have N Customers. Each Customer instance has its own number which is unique and its prefix is base on number of User instance.

This is not really a matter of a dynamic prefix but multiple sequences.

In order to have a numbering sequence for each user’s customers you need to create a separate sequence for each user. This should preferably occur automatically. So you need to:

  • Create a Sequential Workflow that will create a new number sequence based on the user’s short-code. The short-code can be used also as a prefix (CounterDetail.Prefix)
  • Create a State Workflow that will run on User entity on a RecordCreated event. It will execute the sequential workflow created in the first step.

This way a new number sequence will be created for a newly added user. Later when creating a customer you will use an XPath function AS:GenerateSerial(User\@ShortCode). Since the number sequence with this code will be maintained you will get a unique number for each user’s customer.