Replace ttResults for Kinetic

Good morning all,
I just wanted to post this for posterity. I had a hard time finding an old post I saw by Jose talking about how ttResults was replaced by a dataset reference. I had to update some old code and couldn’t find the post.
Do you get an error “ttResults does not exist in the current context.”?

Just replace ttResults with queryResultDataset.Results.

In my code it was:

foreach (var ttResults_iterator in (from ttResults_Row in ttResults where ttResults_Row.Unchanged() select ttResults_Row)) 

and I updated it to:

foreach (var ttResults_iterator in (from ttResults_Row in queryResultDataset.Results where ttResults_Row.Unchanged() select ttResults_Row)) 

You might also have used something like this in the past: from uBAQ BPM - Custom Code Help - ERP 10 - Epicor User Help Forum (epiusers.help)

var results = ttResults.FirstOrDefault();

but now, you want to use this:

var results = queryResultDataset.Results;

Note on the above, I am not sure about pulling the first or default. But, replacing the ttResults is the way to start.
Hope this helps someone!

It’s different in each screen.

BAQ stuff is queryResultDataset.Results.
Data Directive is still ttTable
Method Directive is ds.Table

So annoying trying to remember which one to use.

4 Likes

Thank you for that!!

1 Like

Yup… things have changed…
ALSO… you should consider changing your line to be “better” for the system.

You currently have:

foreach (var ttResults_iterator in (from ttResults_Row in queryResultDataset.Results where ttResults_Row.Unchanged() select ttResults_Row)) 

but to make the system more efficient with the data, and to make this more readable, you should do the following:

  1. do the query and get the results
  2. THEN do the foreach on the results.
    Like this:
var myResults = queryResultDataset.Results.Where(x=>x.Unchanged());
foreach (var result in myResults) {
   //do your work here
}

Reason? From what I am told, when you have the query built into the foreach, it leaves the query open and is retrieving inefficiently… but when you do the one query first, it is faster. Also, (in my opinion) this is easier to read.(I hate that old “Iterator” variable)

5 Likes

Thats great to know! Thanks @timshuwy!!!