Re: SKU lookup
This WebDNA talk-list message is from 1997
It keeps the original formatting.
numero = 13100
interpreted = N
texte = At 12:38 AM 8/21/97, you wrote:>Hello>>Hey how would one write an expression to lookup the last SKU entry made>in a given db, and then add 1 to it, and enter that automatically in the>SKU field?>-- As Ken mentions, the [cart] is great for generating unique skus. However,sometimes you might require a unique sku which is not a random number suchas 8721054256023 which is the sort of number you get by using [cart].For example, what if you are making an employee database and you want totrack it using a logical progression (1, 2, 3 etc.) with each newemployee's number being one higher than the last.Here is a snippet of code to take the highest sku value from a database andthen increment it by one:[search db=yourdatabase.db&grskudata=0&skusort=1][founditems][name][math]newsku=[sku][/math][/founditems][/search][math]newsku=(newsku+1)[/math]
Final value=[math]newsku[/math]
To hide the output from a [math][/math] context just enclose it like soThis lets the code get parsed without displaying the results.To call the newsku value elsewhere in the template just use[math]newsku[/math].....................................................................W O R L D P O I N T I N T E R A C T I V E DANIEL CAMERON web engineerHonolulu San Francisco 2800 woodlawn drive 222 sutter street dcameron@worldpoint.com suite 170 sixth floor www.worldpoint.com honolulu, hi 96822 san francisco, ca 94108 voice.808.539.3932 fax.808.539.3943 cell.808.291.1610.....................................................................
Associated Messages, from the most recent to the oldest:
At 12:38 AM 8/21/97, you wrote:>Hello>>Hey how would one write an expression to lookup the last SKU entry made>in a given db, and then add 1 to it, and enter that automatically in the>SKU field?>-- As Ken mentions, the
[cart] is great for generating unique skus. However,sometimes you might require a unique sku which is not a random number suchas 8721054256023 which is the sort of number you get by using
[cart].For example, what if you are making an employee database and you want totrack it using a logical progression (1, 2, 3 etc.) with each newemployee's number being one higher than the last.Here is a snippet of code to take the highest sku value from a database andthen increment it by one:[search db=yourdatabase.db&grskudata=0&skusort=1]
[founditems][name]
[math]newsku=[sku][/math][/founditems][/search]
[math]newsku=(newsku+1)[/math]
Final value=[math]newsku[/math]
To hide the output from a
[math][/math] context just enclose it like so[math]newsku=[sku][/math]>This lets the code get parsed without displaying the results.To call the newsku value elsewhere in the template just use
[math]newsku[/math].....................................................................W O R L D P O I N T I N T E R A C T I V E DANIEL CAMERON web engineerHonolulu San Francisco 2800 woodlawn drive 222 sutter street dcameron@worldpoint.com suite 170 sixth floor www.worldpoint.com honolulu, hi 96822 san francisco, ca 94108 voice.808.539.3932 fax.808.539.3943 cell.808.291.1610.....................................................................
Daniel Cameron
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
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...
Related Readings:
E-mail doesn't have break-returns! (2002)
Suddenly can't see files... (2000)
Uploading out of FMP (2001)
New index for docs (1997)
Smart caching problems with 2.1b3? (1997)
CommandSecurity? (1997)
WCS Newbie question (1997)
[WebDNA] Rewrite url (2013)
Shhh... (2006)
[addlineitems] (1997)
Webcat2, WebCommerce, Mod 10 etc. (1997)
SiteGuard Admin Feature ? (1997)
[WebDNA] copy some database fields into a new database (2016)
carriage returns in data (1997)
Convertchars Problem (2004)
Moment of Thanks (1997)
Users.db (1998)
[SearchString] usage (1997)
WebCat2b15MacPlugin - showing [math] (1997)
Mac Webcat 3.0.3b1 memory leak redirect inside search (1998)