Can we extract list of all analysis going on on a particular element template?
Interesting question. One of the coolest features of AF is templating, and with analyses you have templates with templates. That is, an element template can have many analysis templates. It makes deploying large systems easier since you can define 1 element template with (for example) a dozen analysis templates. Later when you create 10K elements based on that 1 element template, AF will also create 120K analyses. Makes administration easy!
But you've touched on a problem. Hey, all I did was create 1 element template and 12 analysis templates. How do I find those 120K analyses that were created on my behalf?!
There are a few different ways you can do this, some of which perform better than others under different scenarios. It also depends upon what objects you already have defined. Obviously, you will need an AFDatabase object, and it would help to have an AFElementTemplate object. If you have the object already, you could check its AFElementTemplate.AnalysisTemplates Property.
One way, it involves at least 2 different steps, some of which may require repeated calls to the AF server. The first major step is to find all analysis templates belonging to an element template (see above). The second major step would be to search each analysis template and list out each found items Target where Target is an AFElement. Note: as of this writing, AFElement is the only possible type for a Target, but that could change in the future. Note Target comes back as an Object, so you would want to cast As AFElement.
The problem with the above is the number of trips to the server (13 - actually more thanks to AFSearch paging but let's focus on the 13). You require 1 trip for AFElementTemplate.AnalysisTemplates Property , and then a separate trip per analysis template, which is 12 more trips. You will want to do a full load so you may check found object's Target As AFElement.
But there is another way with fewer trips. The element template contains analysis templates. And creating element instances from that element template will also create the analyses. So you could just query all the elements created from that element template, without specific concern to the analysis templates. This would be useful if everything was created in a good order. If this was not the case and you expect there are gaps of elements that should have an analysis but don't, I would not use this for this given maintenance task.
Retrieving data ...