Submitted by viking on 2022/02/09 05:14

Can I use script to find out an Item's Tags?

Comments

In v119 you'll be able to use Item Tags in equations:

  • New: Tags: Item Tags can be used in Forms and Field equations. Use the ItemTags field (returns a comma separated list of tag names. i.e. #Tag1, #Tag2)

Great!
So when I create a new item, it can trigger a rule to check if the new item was assign Tag1. If so, it can take action e.g. color the item red.
It would almost be like having auto-assignment rules for Tags :-).

 

BTW, when I change an item's Tags would that correspond to modifying the item (So that I could use the M flag for the item to trigger a rule)?

Well, I initially didn't it would work because the ItemTags field isn't available in the Manage Fields dialog, but...

In v119:

  • New: Tags: ItemTagCount field can now be used for Auto-Assign. Enter rules and these will be triggered whenever Item Tag are modified

So even though Tags cannot trigger Auto-assign rules, the field ItemTagCount can. Use this field to trigger actions whenever item tags are added / removed. For example, the rule  M:[Notes]=[ItemTags] will save the list of tag in the Notes field

    You could, but your best bet is to pass through an text field. You could use the old WikiTag field for this. Just ensure you change the multi-select parameters to enclose with # and a space character, clear Separate values by.

    1. In ItemTagCount, enter the following rule M: [WikiTag]=[ItemTags]
    2. In the WikiTag field, add a list of Auto-assign rules to do what you want, perhaps using so Visual Basic code

     

    I tried this - I made a text field "Multi Select Test", and selected the "Auto-List of Values" editor, and in Multi-Select settings, enclosed values with "#" and " ", and cleared the "Separate values by" box.

     

    manage fields dialog multi-select options

    Unfortunately the values were not listed separately in the popup box.  

    multi-select box

    So, i'm guessing that if I auto-assigned [ItemTags] to [WikiTags] (or some other text field), the Sync Matching Fields option would not work because the tags are not recognized as multiple separate tags?

    When I changed "Enclose values with" to "#" and "#", and "Separate values by" with " ", the values were listed separately.

     

    1.    I manually added the "Weight2" tag to the item.
    1a.    The ItemTagCount field value increased by one.
    1b.  The Autoassign rule for the ItemTagCount field "M:[WikiTag]=[ItemTags]" fired.
    2.  "#weight2" was added to the WikiTag field.
    3.  Because "Sync Matching Fields" is turned on in the Multi-Select Options for the WikiTags field, the "weight2" yes/no field is checked to match the "#weight2" tag in the WikiTag field.

    In this way the "Weight2" tag was synced to a matching yes/no field.

    "Sync Matching Fields" won't create a yes/no field to match the added WikiTag; the Yes/No field must already exist.

    When I delete the #weight2 tag from the item, "#weight2" is deleted from the WikiTag field, and the "weight2" yes/no field is unchecked.

    tag syncing to field

     

    How do I ?