I'm building an electronic parts database in D7 and want to create a custom "part" entity with bundles for resistors, capacitors, etc.

I also need to autocreate an atomic serial part number common to all bundles, i.e no separate part numbering system per bundle. I was going to use the Serial module but it only works with nodes. In D6 I did everything in nodes for a similar application and just used the NID, but this parts DB really wants a cleaner solution using entities. I'd like to use the entity ID as the serial part number but only if it's unique per custom entity type.

Question is: Does each custom entity type I create have its own set of entity IDs or is it like in D6 with nodes where NIDs apply across all content types?

  • Per entity type, I think. But I'm not sure. And by the way, consider UUID.
    – Mołot
    Commented Jan 22, 2014 at 8:16
  • I think you may also be confusing entity type with bundle. Bundles in D7+ are what are analogous to content types in D6-.
    – mpdonadio
    Commented Jan 22, 2014 at 14:49

3 Answers 3


Each entity type has it's own ID sequence. For example a user may have the uid of 1 while a node may also have an nid of 1. Similarly a taxonomy term may have a tid of 1. In all those cases the "entity_id" is 1.

Regarding the serial module, as it provides a field via the Field API, presumably that field could be attached to any entity bundle.

In regards to linking your entities, you could probably use the entityreference module to create reference links between your entities.


Each entity type maintains its own IDs, they're not related to the IDs of any other entity type.

So you can easily have node/1, taxonomy_term/1, entityform/1, custom_entity/1, etc. You can't use the ID as a unique field across different types of entity.

As Mołot mentioned in the comments, the UUID module goes some way to solving your problem.


Ok, I'll just use the entity ID as my "part number" as it's unique to that entity type. I'll also use Computed Field to start the sequence at 1000000001 or something like that.

UUID generates a hash, not a sequential number like 0004538615 which is what I want. A long alphanumeric hash would be too confusing. Part numbers get referenced by vendors on purchase orders, for example.

I will have a custom entity type called "Parts" and bundles for categories like resistors, capacitors, etc. That way a sequential part number will be created for every new record no matter which bundle triggered it.

The Serial Field module doesn't work with entities, only nodes. Some work has been done about that but the thread went dead 9 months ago.

Thanks for the answers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.