How to properly get multiple tags with GetDevicesWithTags? With Feedback.

This is both a question and feedback!

Question: How do we get multiple tags using GetDevicesWithTags?

Currently you can GetDevicesWithTag easily like so:

MyDevice := GetDevicesWithTag( MyTag{} ).

This works nicely, however its not clear how to get multiple tags! First, we need a new function. I don’t believe 2 seperate functions should be needed, instead keep a single function of GetDevicesWithTags that works with both single and multiple tags.

The cleanest and most logical way for me to do this would be like so:

For a single tag:
MyTaggedDevice := GetDevicesWithTags( array = { MyTag1{} } )
For multiple tags:
MyTaggedDevices := GetDevicesWithTags( array = { MyTag1{}, MyTag2{} } )

Hi,

To query for objects in more complex ways than just using a single tag the way to do it is currently using the GetCreativeObjectsWithTags function with a tag_search_criteria:

# All creative objects with MyTag1
ObjectsWithMyTag1 := GetCreativeObjectsWithTag( MyTag1{} )

# All creative objects with MyTag1 AND MyTag2
ObjectsWithMyTag1AndMyTag2 := GetCreativeObjectsWithTags(tag_search_criteria{RequiredTags := array{MyTag1{}, MyTag2{}}})

# All creative objects with MyTag1 OR MyTag2
ObjectsWithMyTag1OrMyTag2 := GetCreativeObjectsWithTags(tag_search_criteria{PreferredTags := array{MyTag1{}, MyTag2{}}})

# All creative objects with MyTag1 OR MyTag2 that do NOT have MyTag3
ObjectsWithMyTag1ORMyTag2ButNotMyTag3 := GetCreativeObjectsWithTags(tag_search_criteria{PreferredTags := array{MyTag1{}, MyTag2{}}, ExclusionTags := array{MyTag3{}}})

, given tags defined like this:

MyTag1 := class(tag):

MyTag2 := class(tag):

MyTag3 := class(tag):

. Note that what used to be called GetCreativeDevicesWithTag is called GetCreativeObjectsWithTag in future releases. We will take your feedback regarding just having one function into consideration.

// K

5 Likes

Thank you for the response!

Does this still work in verse? Because it says “GetCreativeObjectsWithTag” is now deprecated and to use FindCreativeObjectsWithTag. I’m trying to use the “tag_search_criteria” now with the new function, but it gives some errors like it doesn’t recognize it.

(can ignore the multiple array of tagged items, trying to make a new array called tagged_beaconList_all)

So this is the function call they used to use from the digest:

@deprecated
# Deprecated, use `FindCreativeObjectsWithTag` instead.
# Returns an array containing creative objects which have tag(s) matching the specified `SearchCriteria`.
GetCreativeObjectsWithTags<native><public>(SearchCriteria:tag_search_criteria)<transacts>:[]creative_object_interface

There is no such overload for ‘FindCreativeObjectsWithTag’. Not sure why they wouldn’t write one. You’ll have to do some extra checking in verse.

this may help:

# Returns a queryable `tag_view` which can be used to query the tags on `CreativeObject`.
    (CreativeObject:creative_object_interface).GetTags<native><public>():tag_view
1 Like

omg this will help so much thanks! I will try it out when I get a chance!

1 Like