Adding multiple tags based on condition

I have about 140 UDTs that I want to add all the tags in the UDT based on the condition of another tag in the UDT. Each tag has a grade from 0-5 and I want to get the some of all the totalTare that are grade 1, 2, 3 etc. The totalTare is actually a total of multiple loads in a SQL database. What would be an efficient way to go about doing this?

It depends a bit on your project structure.

You can start with a BrowseTags call in a script (https://docs.inductiveautomation.com/display/DOC/system.tag.browseTags), you can browse based on path and UDT parent type.

Once you have these tags, you can loop through them and get the full tag path for each tag. Then with the tag path, you can get the _Grade and totalTare and add the totalTare to the right value based on the _Grade.