Unique Reference Number for Collection Items using Loops
ATTENTION: THIS IS OUR OLD SITE. TO SEE OUR NEW WEBSITE, CLICK HERE.
Create unique reference numbers for each item in your dynamic collection using loops. Unique reference numbers are an easy way for you or your website users to search or locate a specific item in your collection. This method is not impacted if records are subsequently removed from the collection.
The best time to add a unique reference number to a dynamic item in your collection is at the point the item is created. This explanation assumes you already know how to create a standard form for entering your data into a collection. In addition to the write only dataset which your form will populate with data, we will add a second instance of the same dataset which will be assigned to read only. The reason for this is that we cannot reference write only datasets in a loop, and read/write datasets are not suitable for form entry. The screenshot below shows two datasets: #dbCodeBank (write only) and #dbCodeBank2 (read only) used in this example. We also create a field in the collection to store the unique reference number, called 'itemNumber' in this example.
Please login or sign-up (it's free!) to view our code. Refresh the page if already logged in.
Disclaimer: To the best of our knowledge, this code works for its stipulated purpose. If you find an error in our code, or know of a better way to achieve the same result - please contact us! We will help where we can, however please be aware that the code is provided 'as is' and without a promise of support in using or implementing it.