Unique ID's - User/Category level

By: Rudi JvR | Asked: 09/17/2023
ForumsCategory: General questionsUnique ID's - User/Category level
Rudi JvR asked 7 months ago
I'm in need of advice, any suggestions of how to approach this would be much appreciated:
  • Users capture entries into a personal inventory using a form referencing a master database (master form) using lookup fields.
  • On the Personal capture form I require a Unique ID to be generated for each entry to a user's personal inventory
  • The ID should be unique by logged in User, as well as a selected "Category" (lookup from master form/DB) of the entry captured
I'm hoping there is a simple solution to this requirement before I dive into developing a custom SQL lookup table table to be queried for every new inventory entry. Thanks!  
1 Answers
Best Answer
Victor Font answered 7 months ago
Every entry has a unique entry id and key. Are these fields insufficient? Also, add the user id field to the form. I don’t understand what you mean by category. The best approach is to use dynamic lookup fields. https://formidableforms.com/knowledgebase/dynamic/#kb-additional-customizations
Rudi JvR replied 7 months ago

Yes I don't want just a random Key or system ID, I want a bit more control over the number generated and it should be user specific.

The ID should start at 1 and increment for every new entry. This ID will form part of a concatenated KEY I will build up for each entry to a user's inventory. Think of the requirement as a SKU type code used for stock management.

The incremental ID should be unique at the level of the Master entry's Category selected. The category exist in the master form as a hierarchy of lookup fields to filter the next level down.

Rudi JvR replied 7 months ago

I had a look at [auto_id], but I'm not sure how I can utilize this function to identify the next number (start=x) sequence for the logged in user based on the lookup selection (category).

For example, 2 different users using my application:

1.) User_ID 3:
- User_ID 3 is logged in
- User_ID 3 is adding 2 new entries to his personal inventory, 1 Fruit and 1 Vegetable
- User_ID 3 already has 7 entries in his inventory for Category "Fruit"
- User_ID 3 is capturing a new "Fruit" entry, this fruit should be assigned an ID of 8
- User_ID 3 already has 5 entries in his inventory for Category "Vegetable"
- User_ID 3 is capturing a new "Vegetable" entry, this vegetable should be assigned an ID of 5

2.) User_ID 10:
- User_ID 10 is logged in
- User_ID 10 is adding 2 new entries to his personal inventory, 1 Fruit and 1 Vegetable
- User_ID 10 already has 3 entries in his inventory for Category "Fruit"
- User_ID 10 is capturing a new "Fruit" entry, this fruit should be assigned an ID of 4
- User_ID 10 already has 1 entries in his inventory for Category "Vegetable"
- User_ID 10 is capturing a new "Vegetable" entry, this vegetable should be assigned an ID of 2

With this example, how can I know what the "start=?" ([auto_id start=?]) value should be for the current user, based on existing entries by Category "Fruit" or "Veg"?

Victor Font replied 7 months ago

There’s no way to do this they way you’ve designed your process without custom code. You’ll need to use either a custom shortcode that you write or the frm_after_create_entry hook (preferred method)

Rudi JvR replied 7 months ago

I was hoping there is a simpler solution which might've evaded me, but suspected that it might require bespoke development.

Thanks for the help!

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right