Toggle sidebar view based on metadata

I have a simple on/off custom metadata to indicate if a group is inactive. I would like to be able to toggle views in which only active groups (inactive==0), only inactive groups (inactive==1), or both are shown in the sidebar below any selected parent group. This is easy to do in the list view using a query. Is this possible to do in the sidebar?

I can make separate smart groups for each state, but this would require making three smart groups for each possible parent group for which I want to toggle the view (one for active, inactive, and both).

To further clarify, if the sidebar current shows the default view:
PARENT GROUP
– CHILD GROUP 1 (inactive==1)
– CHILD GROUP 2 (inactive==0)

I want an easy way to toggle (in the sidebar – not the list view) between the default view and showing:
PARENT GROUP
– CHILD GROUP 1 (inactive==1)

and
PARENT GROUP
– CHILD GROUP 2 (inactive==0)

Is this possible? Thanks in advance.

There is no hidden state for groups, so no this is not possible.
Also, a toolbar search isn’t hiding anything. Things either match the search criteria or they don’t.

1 Like

I am looking into trying to make this work again and have another set of questions.

I am thinking of a script that modifies the search conditions of the selected smart group in a specified way, allowing me to rotate through the different search options I want. However, I don’t want to create a new smart group, I want to modify the search conditions of the active smart group (the one a selected item is within). I cannot find a way to find the UUID of the active smart group I am in. I know that this cannot be done through the selected item alone because the smart group is just a saved search - it is not permanently connected to the items within it. However, is there anyway for a script to know the UUID of the smart group the cursor is in when it is called? I can see which smart group the item is in when I select it, so I thought maybe there is someway for a script to know it too.

As an example, take the screenshot below of an item selected within a smart group (in this case ‘Indexed Folders’) - if I run a script in this state, is there any way for the script to identify the UUID of the smart group ‘Indexed Folders’?

Screen Shot 2022-01-23 at 10.40.15 AM

What you want is possible, however you need to

  • select one Smart Group in the navigation sidebar

and

  • select one or more records in the item list (or one of the other views)

i.e. you can’t select the record in the sidebar as you’ve done in your capture.

If you select the Smart Group in the sidebar then the viewer window’s root property returns the Smart Group.

-- Set query of Smart Group that's selected in the sidebar

tell application id "DNtp"
	try
		if not (exists viewer window 1) then error "Please open a viewer window"
		
		try
			set theRoot to root of viewer window 1
		on error
			error "Please select only one smart group in the sidebar"
		end try
		
		set theRoot_Type to (type of theRoot) as string
		if theRoot_Type is in {"smart group", "«constant ****DTsg»"} then
			set theSmartGroup to theRoot -- easier to understand  			
			set search predicates of theSmartGroup to "kind:markdown name:Test"
		else
			error "Please select a smart group in the sidebar"
		end if
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		return
	end try
end tell