Forum Discussion

benjamin_brooking's avatar
9 years ago

Federation - Item count

Hello, I've created a federated ItemType to pull in data from an ODBC data source and it seems to be working great apart from one thing: When running a search the status bar at the bottom reports '0 items found', and consequently you can't page through the results. 25 results do actually appear on screen though! Looking at the results in AML Studio I can't see any difference between what my onGet returns and the results of any other query on a normal native ItemType, so I'm not sure how I'm supposed to communicate the number of results (and page number) to the UI. To save uploading all my code, my results are assembled by:
  • Create inn.newItem("my federated type")
  • Set attributes and properties
  • Get AML of new Item and append to string
  • Repeat this for all results
  • Strip the isNew and isTemp attributes from the AML
  • Wrap in <Result> tags
  • Return via inn.newItem().LoadAML(mystring);
This is probably the most roundabout way of assembling a result set but I couldn't find any better way that worked at least as far as I've got. Any pointers to documentation on how to do this better, or ideas on how to handle the item count gratefully received. Many thanks in advance, Ben ps. We're on V11 SP5

2 Replies

  • Thanks, that's much better. In the interest of efficiency I was trying to keep it so that my queries to my external database were only for the page of results being requested by the user. Based on this method I assume that I need to return all 6000-odd (or found subset) records in my database for the paging to work? Is there no way to report back the total records and current range without returning the actual data too? Many thanks, Ben
  • HI, You can try it. Server Event :OnGet   Innovator innovator = this.getInnovator(); ArasTool aras = new ArasTool(innovator); string queryString = "select cname from customer"; string dbConn = "XXX"; Item res5 = null; Item res = this.getInnovator().newResult(""); try { XmlElement resultNd = (XmlElement) res.dom.SelectSingleNode("/*/*/*"); DataTable dt = aras.getDataTable(dbConn,queryString); foreach (DataRow dr in dt.Rows){ res5 = this.newItem("customer"); string newid = getNewID(); res5.setID(newid); res5 = res5.apply(); res5.setProperty("_cname",dr["cname"].ToString()); resultNd.AppendChild(resultNd.OwnerDocument.ImportNode(res5.node, true)); } } catch (Exception ex) { CCO.Utilities.WriteDebug("DebugFile",ex.ToString()); } return res;