numero = 11624
interpreted = N
texte = >>>>>Is there a way for new records appended by WebCat 2.0>>>>>to generate sku numbers?>>>The code I use is as follows:>>>>>A more reliable method for creating a unique record number is this:>>>>... because [cart] will create a unique number even when two or more people>>attempt to create a new record in the very same second.>The trouble I found with using a cart value for a SKU is that if a user is>adding multiple records they might use the browsers back button to return>to the add_record.tmpl. If that happens then they will entering records>with identical cart values.>>I'm not sure what the ideal technique would be as both cart and date have>their inherent drawbacks. I decided that the chances of having records>entered at the exact same second is less than the chance of someone using>their back button. Perhaps Grant can advise us or perhaps give us a true>random command or math context that we could compute with... Unless Ken,>you being the WebDNA guru that you are, have found a way around the back>button problem.Well ... I have an idea that should work every time - even if you reset theserver's clock back - and it forever resolves the problem with the Backbutton:1- Instead of creating the new record directly from the form itself, passall the form field values - including the hidden sku=[cart] value - to theresults page.2- On the results page, put a [search] context that searches the databasefor the newly-created sku value.3- Use showif/hideif within a [lookup] to do one of the following (#4 or #5):4- If the [lookup] can NOT find the new sku value in the sku field of thedatabase, append the new record to the database by using an [append]context on this page. I would also suggest that you display a messagesomething like this to your users ... Thanks for creating a new record! Ifyou want to create another new record, do NOT use the Back button on yourweb browser. Instead, click here to load a newblank form.5- If the [lookup] DOES find the new sku value in the database (onlypossible when the same user clicked the Back button to create this newrecord), do NOT append the new data. Instead, give the user a reply thatsays something like this ... Sorry, we cannot create this new recordbecause you used the Back button to create a new record. Instead of usingthe Back button this time, please click here tocreate a new record.6- Please note: When you place here into yourpage, it does NOT cause the browser to reload the previous page - it causesthe server to send that page, which means a new [cart] value will becreated when the form is submitted.7- The reason I mentioned that this will work when you set your computer'sclock back is because [cart] values (and also your VALUE=[DATE%Y%m%d%H%M%S] technique) are based on the server's clock ... and if you setthat clock back, there's a chance that WebCat might create the same [cart]value that is has already created sometime earlier.Fortunately, using a [lookup] to check the sku value of every new recordagainst the values in the database, this essentially prevents the same skuvalue from EVER being re-entered again - unless you do it manually or withanother set of forms that do not have these safeguards built into them ...:)Sincerely, Ken Grome ..... ken@iav.comhttp://usarea.net/home.html
Associated Messages, from the most recent to the oldest:
>>>>>Is there a way for new records appended by WebCat 2.0>>>>>to generate sku numbers?>>>The code I use is as follows:>>>>>A more reliable method for creating a unique record number is this:>>[cart]>>>... because [cart] will create a unique number even when two or more people>>attempt to create a new record in the very same second.>The trouble I found with using a cart value for a SKU is that if a user is>adding multiple records they might use the browsers back button to return>to the add_record.tmpl. If that happens then they will entering records>with identical cart values.>>I'm not sure what the ideal technique would be as both cart and date have>their inherent drawbacks. I decided that the chances of having records>entered at the exact same second is less than the chance of someone using>their back button. Perhaps Grant can advise us or perhaps give us a true>random command or math context that we could compute with... Unless Ken,>you being the WebDNA guru that you are, have found a way around the back>button problem.Well ... I have an idea that should work every time - even if you reset theserver's clock back - and it forever resolves the problem with the Backbutton:1- Instead of creating the new record directly from the form itself, passall the form field values - including the hidden sku=[cart] value - to theresults page.2- On the results page, put a [search] context that searches the databasefor the newly-created sku value.3- Use showif/hideif within a [lookup] to do one of the following (#4 or #5):4- If the [lookup] can NOT find the new sku value in the sku field of thedatabase, append the new record to the database by using an [append]context on this page. I would also suggest that you display a messagesomething like this to your users ... Thanks for creating a new record! Ifyou want to create another new record, do NOT use the Back button on yourweb browser. Instead, click [referrer]>here to load a newblank form.5- If the [lookup] DOES find the new sku value in the database (onlypossible when the same user clicked the Back button to create this newrecord), do NOT append the new data. Instead, give the user a reply thatsays something like this ... Sorry, we cannot create this new recordbecause you used the Back button to create a new record. Instead of usingthe Back button this time, please click [referrer]>here tocreate a new record.6- Please note: When you place [referrer]>here into yourpage, it does NOT cause the browser to reload the previous page - it causesthe server to send that page, which means a new [cart] value will becreated when the form is submitted.7- The reason I mentioned that this will work when you set your computer'sclock back is because [cart] values (and also your VALUE=[DATE%Y%m%d%H%M%S] technique) are based on the server's clock ... and if you setthat clock back, there's a chance that WebCat might create the same [cart]value that is has already created sometime earlier.Fortunately, using a [lookup] to check the sku value of every new recordagainst the values in the database, this essentially prevents the same skuvalue from EVER being re-entered again - unless you do it manually or withanother set of forms that do not have these safeguards built into them ...:)Sincerely, Ken Grome ..... ken@iav.comhttp://usarea.net/home.html
Kenneth Grome
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...