I was working with portals this week and noted the following:
a) I was getting bizare results when querying data displayed in a portal I think because the data displayed in the portal was not saved to the backend database. Problem resolved when I would reload data in the primary form prior to doing a query on the data displayed in the portal.
// I did this to force it to save the data in the portal prior to querying
var foundset = controller.duplicateFoundSet()
controller.loadRecords(foundset)
I looked at this again. I only see the problem if I query a table immediatly after altering the tables data via a portal. I am able to get around the problem with controller.saveData().