Forum Academy Marketplace Showcase Pricing Features

Adding an item to list that exists

Please help… I hope this is possible or im screwed…

I would like to add an item to a list even if it exists. I’m adding numbers to a list and its possible to have multiples of the same number. But when I do make change to a thing, add a number to a list it wont add because it exists somewhere in the list…

I have run into this issue before. I had to do a work around by making all items in the list unique. For example, I had a price field (not all prices are unique) but when I tried to add a price to the list, if the price already existed, it wouldn’t add it. So I changed the price field to be 19.99|x where x was the id. This way it guaranteed everything in the price field to be unique. When I wanted to pull the price later on, I just used “extract with regex” to remove the “|x” and then used “:converted to a number” to change from text to number.

Hope that helps

Well, i guess that kinda works, hell of a workaround. Wish there was an easier way :confused: thanks paul.

Create a separate data type called “ListItem”

That listItem data type would include a data field for the item

Everytime the User wants to add that item, you would create a new DB entry “ListItem” and associate it with the “List”

Would that work?
Learn no code → nocodify.com

1 Like

Not quite. It would get to messy if I did it that way.

BUT, one thing I could pull off is adding a random string of number to the end as a decimal. So say my number is 15 and using Paul’s method I would like to add 4 decimal number at random. This would make the number unique. Like 15.4589 if I did that I can continue with my app … does anyone know the best way to do that ?

I can generate a random string but its a whole number , not a decimal. How to I convert it to a decimal?

Tick of “use numbers” only then add “:converted to a number” at the end
image

I would also advise against only using 4 decimal places. If you only use that many, then there is about a 1% chance of having 2 numbers be the same if you only have 100 different records in your list of things. As that number increases, the chance of 2 being the same drastically increases. This is known as the birthday paradox. It’s very easy to include more decimal places to give yourself a basically 0% chance of having two numbers be the same

Paul,

So I did exactly this. Which is precisely were im stuck… B.c this gives me a random whole number… I want to generate random decimal number. My function look like( add 15 + calculate randomstring:converted to number) … which comes out 8015… but I would like it to be 15.8000… know what I mean ?

I’m not at my computer right now so I can’t test it out and don’t remember how order of operations works on bubble off the top of my head but I think it works from left to right so if you just divide your randomly generated number by 10,000 then that should work

Brilliant ! Thanks :smiley:

Better yet,

Divide it by an extra 0 (100000), now you have a number which is separated by a decimal and a 0 followed by random numbers which is like ur unique id. And if u want to use your number you just have to round to the whole number and you remove all the bull#$% we had to work around with :smiley:

Glad it worked. Happy to help