Creating unique item codes on a running file

Hi Everyone!

I need help on a workflow. I have a running file of inventory and I want to assign unique codes to them every time I add a new item on my master list

e.g.
Item - Code
Chair - CH0001
Chair - CH0002
Table - TB0001
Vase - VS0001
Table - TB0002

my problem is this master list is a running excel sheet so ill be appending my list with new items coming every time I run the workflow with new source file. If I want to add lets say more chairs and vases, what node shall I use so that the item code that will be automatically generated is subsequent to the existing ones

thank you all in advance!

Hello @kelvinlazam,

and welcome to KNIME Community!

You can make use of Rank node to get unique id per item by specifying grouping column inside it and Ordinal as Mode. After that Rule Engine node can be used to add prefix (CH, TB…) depending on item and finish it off with String Manipulation node to create desired code using join() function for joining and padLeft() for 4 digit part of it.

Give it a try and let us know how it went!

Br,
Ivan

3 Likes

Thank you so much for the quick response! ill definitely try this

1 Like

Hi Again!

By any chance do you know how I can format the rank node output into this format?

00001
00002
.
.
.
.
00011
00012
.
.
.
.
.
00100
00101

and so on?

thanks!

@kelvinlazam you can do it like this. Converting the rank into string. determining the length and then adding leading zeros to the rank variable:

3 Likes

oh cool!

is it possible for me to get a copy of the workflow? I want to understand the configurations.

thanks!

@kelvinlazam you can download the workflow from the KNIME Hub like this:

1 Like