I am having an issue of being able to check if a certain object exists once the data-loop starts. I have two 'If Object' statements. Both are looking at the text value of a search box. On the first run the program successfully checks to see if the object exists (but it will not exist), then continues to run the actions under that 'if object' statement. On the second run (the object exists) it continues to run the actions under the 'if object' statement that looks to see if the object does not exists. How do I make it so the check object refreshes and runs the correct 'if object' statements?
One thing up front... in the "Else" block, you don't need the additional "if object" for not exists... that's what "Else" does... your first "if object" checks for existance... if exists is true, it executes that block of operations... if not, whatever is under the "else" executes so you don't need to recheck.
Secondly, it's not clear what the "Exists[Get]" on a different page object is intended to do. You're just getting the property value but then it's not obvious what you're doing with it.
Now, all that said... It would be interesting to see two things... first, what are the actual parameters for your initial "If object" statement... could you give us a screenshot of what's inside there? Secondly, what is actually being executed in the two code blocks (the initial "if object" and the "else"). What it SOUNDS like, as has been hinted by others here, is that your object that you are checking may be getting dynamically destroyed and recreated somehow. One of the things that TestComplete does is it caches objects that have been namemapped. So, if an object is destroyed and recreated, some of the handles and everything may not be valid the next time through. This is where calling "RefreshMappingInfo" on some parent object (such as the page) would make sure that TestComplete has a "clean" picture of the objects present. Try adding that operation on the pagePiLeaseSearch before you're "if exists" and see if that helps.
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group. I love good food, good books, good friends, and good fun.