.addTags

Hi,

I’m trying

const myItem = items.getItem('myItem')
const newTags = [a,b,c,d].toString() // an array as a string. Comes from somewhere else, but not relevant here. It's definitely a string.
myItem.addTags(newTags)

but only one long tag with all commas included is applied to the item.
This does not accept an array object, it needs a string, so I don’t know why this isn’t working.

On OH4

I might be on to something. .addTags needs to get multiple strings, separated by a comma.

so…

myItem.addTags("a", "b", "c")

not

myItem.addTags("a,b,c")

How can I turn my string of “a,b,c” into something I can use?

Got it.

const myItem = items.getItem('myItem')
const newTags = [a,b,c,d]

tags.forEach(tag => {
    myItem.removeTags(tag)
});
1 Like

It shall be removeTag instead of Tags. thanks for posting the solution as well :slight_smile: