How do I get the highest `field_id` value that exists in content of a specific type? I have a content type which, among other things, have a field which contains a unique ID number (this number is used to connect the individual content to related information stored on paper).

When creating new entries I'd like to automatically generate this ID by finding the highest ID already present in the system, and calculating the next ID from that.

I have written a small module (using hook_menu()) which presents the user an interface for adding new content. How can I, from within this module, get the  field_id values of my already existing content? (So that I can calculate which ID a new entry should have?)

Is there any PHP command which can be made to return an array containing all the field_ids from my content type?



Worth to know here is that the system is kinda small (500–1000 entries of my content type, at most). There will also only be a single person entering data at a time. Also, I'm using Drupal 7.
The easiest sulotion I can think about is to use Computed field module and the id field will be computed field.
Then,  in the field read the last value using variable_get() and then update that value using variable_set().