DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot Seem to Iterate through Groups in Data Portal After Loading

I am attempting to itterate through all the groups in the data portal in a script after loading search results from a query with the same script. 

My code works when I run it in a separate script but for what ever reason when I combine the loading and itterating script together, I cannot seem to get the script to actually itterate through the groups in the data portal. 

When I call "logfilewrite "number of groups: " & str(data.Root.ChannelGroups.Count)" it correctly displays the number of groups in the data portal but directly after that, when I try to itterate through the groups via "for each oGrp in data.Root.ChannelGroups" it won't itterate through the the groups. 

Innitically I thought I must have made a syntax error somewhere but when I copy and paste the itteration part of my code into a new script, it runs and performs exactly as expected. Am I missing something? Is something preventing me from loading groups into the data portal then itterating through them in the same script? 

Thanks

 

Option Explicit 'Forces the explicit declaration of all the variables in a script.
dim searchList, oTest, oProp, currentCar, testList(2), testRef
' --- If you need a template for the automated search, use Ctrl-Shift-C in the search input area. ---

Call Navigator.Display.CurrDataFinder.QueryForm.Search()
set searchList = Navigator.Display.CurrDataFinder.ResultsList.ResultsElements
Call searchList.Sort("Test_Vehicle", True)
for each oTest in searchList '''itterated through all tests in search
Navigator.LoadData(oTest)'''load test
do while inStr(Data.Root.ActiveChannelGroup.Name,"Main") < 1 '''checks to make sure group is a "main" group
Data.Root.ChannelGroups.Remove(Data.Root.ActiveChannelGroup.Name) '''deletes all non-"main" groups
Loop
for each oProp in oTest.Properties'''iterate through all properties
if oProp.DisplayName <> "Name" then '''want to add all of files properteries except for the test name
On Error Resume Next '''some properties dont transfer well
call Data.Root.ActiveChannelGroup.Properties.Add(oProp.Name,oProp.Value,oProp.DataType)'''copy to new group
end if
next
next

currentCar = "none" '''init currentCar = "none"
testList(0)= 0 '''init list of tests
testList(1)= 0
testList(2)= 0

call pause(2)
groupSift

sub groupSift()
logfilewrite "number of groups: " & str(data.Root.ChannelGroups.Count)
for each oGrp in data.Root.ChannelGroups '''itterate through all the new groups
logfilewrite oGrp.Name

if currentCar <> oGrp.Properties("Test_Vehicle").Value then '''is test vehicle the same?
logfilewrite "New Vehicle"
testList(0)= 0 '''clears list of tests
testList(1)= 0
testList(2)= 0
currentCar = oGrp.Properties("Test_Vehicle").Value'''changes currentCar
testRef = 0'''sets test ref to 0
end if
logfilewrite inStr(oGrp.Properties("Test_Abbreviation").Value,testList(0))
if testRef = 2 then'''checks if max test for car is reached
Data.Root.ChannelGroups.Remove(oGrp.Name)'''yes? delete group

elseIf instr(oGrp.Properties("Test_Abbreviation").Value,testList(0)) >= 1_
or instr(oGrp.Properties("Test_Abbreviation").Value,testList(1)) >= 1_
or instr(oGrp.Properties("Test_Abbreviation").Value,testList(2)) >= 1 then '''Checks if Test is Already Done
Data.Root.ChannelGroups.Remove(oGrp.Name)'''deletes group
else
testList(testRef) = (oGrp.Properties("Test_Abbreviation").Value)
testRef=testRef+1
end if

next
end sub

0 Kudos
Message 1 of 2
(3,254 Views)

 

Solved.. I feel silly. 

I had called "on Error resume next" earlier in the script so I was not catching errors later on. 

0 Kudos
Message 2 of 2
(3,209 Views)