Setting prefix based on another DB column

Issues related to label design (working with databases, data processing, RFID encoding etc.) and printing (from NiceLabel Express, NiceLabel Pro, NiceForm and NicePrint)

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
kamlesh.chegondi
Newcomer
Posts: 5
Joined: Mon Feb 25, 2019 8:03 pm

Setting prefix based on another DB column

Post by kamlesh.chegondi » Thu Mar 14, 2019 4:40 pm

Hello All,
I need help on how to set a prefix for a variable based on another database column.

For example:
Country and product are two columns from a table in DB.
Country: USA
Product: iPhone

If the country is USA, prefix 'P' to the product barcode
If the country is not USA, prefix '7P' to the product barcode.

Thank you!

User avatar
Kyleodonnell
NiceLabel Support
NiceLabel Support
Posts: 279
Joined: Mon Aug 28, 2017 3:07 pm

Re: Setting prefix based on another DB column

Post by Kyleodonnell » Thu Mar 14, 2019 6:51 pm

Kamlesh

You can do this with a simple script
script.PNG
script.PNG (8.5 KiB) Viewed 1160 times
I have attached a sample that has 2 variables, Barcode and Country. When Country equals USA it will add a P before the barcode value. If it is anything else other than USA it will be 7P.
Attachments
script sample.nlbl
(3.91 KiB) Downloaded 97 times

kamlesh.chegondi
Newcomer
Posts: 5
Joined: Mon Feb 25, 2019 8:03 pm

Re: Setting prefix based on another DB column

Post by kamlesh.chegondi » Thu Mar 14, 2019 8:43 pm

Thank you Kyle!

User avatar
Kyleodonnell
NiceLabel Support
NiceLabel Support
Posts: 279
Joined: Mon Aug 28, 2017 3:07 pm

Re: Setting prefix based on another DB column

Post by Kyleodonnell » Thu Mar 14, 2019 9:16 pm

Kamlesh,

here is an updated sample as the barcode now points to the correct function
Attachments
script sample updated.nlbl
(3.93 KiB) Downloaded 94 times

Post Reply