How to Auto Generate 9 Digit Alpha Numeric Code

10 years 5 months ago #236538 by naturallink
We are developing a website that is required to automatically generate a unique alphanumeric 9 digit code - for example 6F8 9PY 78G

This code will then become a searchable field for users to enter to pull up a specific profile and data set.

This code also needs to be unique to each user and may not be duplicated as it will be printed on stickers and other material unique to each client.

What would be best way forward with community builder to generate this code?

Please Log in to join the conversation.

10 years 5 months ago #236861 by naturallink
Replied by naturallink on topic How to Auto Generate 9 Digit Alpha Numeric Code
Anyone got any feedback on this, or are we going to have to submit a support ticket about it?

Please Log in to join the conversation.

10 years 5 months ago #236868 by krileon
Sorry, missed you topic. Encase this happens please PM the link to your topic if it has been more than 3 days.

Regarding your needs. I suggest creating a Text field that's set to Read Only. Next use CB Auto Actions using a Query action on the after registration trigger. Next you can perform a database query to force a new value to the field using SQL functions to format it to your needs.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

10 years 5 months ago - 10 years 5 months ago #236876 by naturallink
Replied by naturallink on topic How to Auto Generate 9 Digit Alpha Numeric Code
OK that makes sense, however its the auto actions im having problems with as i can find no detailed instructions for it anywhere.

I have alot of experience with joomla, but database queries ill admit - not so strong on.

Because of the nature of the product "patient medical data" its vital the alphanumeric code is unique and needs to be auto created on account registration as the clients requirements could mean 100's of thousands of registrations. To much to do manually.

Please Log in to join the conversation.

10 years 5 months ago #236895 by krileon
For your particular usecase there isn't a tutorial, but there's a few usage tutorials below for CB Auto Actions. There isn't any documentation however as there isn't too much to document as it's a tool and doesn't do anything without specific configurations.

www.joomlapolis.com/support/tutorials/107-use-cases

The below tutorial is probably closest to your usage as it updates a _comprofiler column in one of its actions.

www.joomlapolis.com/support/tutorials/107-use-cases/18219-cb-auto-actions-changing-approval-workflow-based-on-cb-field-value

As for SQL I suggest the below tutorial to get started.

www.w3schools.com/sql/default.asp

To generate a unique string in SQL you'd use UUID(), but it's not going to be in the format you're wanting.

dev.mysql.com/doc/refman/5.6/en/miscellaneous-functions.html#function_uuid

Regarding the format you're wanting I don't really see that being unique enough for 100's of thousands of entries as it's not long enough for that; so if it's possible you may want to just keep the output UUID provides.

The alternative to use SQL is to use a Code action and set its Method to PHP. You could then use PHP to generate your unique id, run database queries to make it isn't used, then update the user object using API. To update a CB user object using API please see the below tutorial.

www.joomlapolis.com/support/tutorials/120-api-usage/18362-registering-a-user-through-cb-api

See the "editUser" code block at the bottom for an example.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: naturallink

Please Log in to join the conversation.

10 years 5 months ago #236902 by naturallink
Replied by naturallink on topic How to Auto Generate 9 Digit Alpha Numeric Code
Thankyou very much, ill have a look at that and let you know how i get on :)

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.233 seconds

Facebook Twitter LinkedIn