11/22/2024 4:55:11 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss building external web applications for SalesLogix. View the code of conduct for posting guidelines.
|
|
|
|
sData not returning all of the data
Posted: 30 Jun 09 1:45 PM
|
when I execute the following
*** snip *** string baseURL = "http://localhost:3333/sdata/slx/"; string dynamicUrl = baseURL + "dynamic/"; string url = dynamicUrl + "/contacts" + criteria; _docContact = GetXDocumentFromString (url);
var contacts = from q in _docAcount.Descendants (_atom + "entry") select q;
*** snip ***
private XDocument GetXDocumentFromString(string uri) { string result = _client.DownloadString (uri); //_client is a properly instantiated System.Net.WebClient class and is functioning properly //remove the Windows UTF NuisanceCode if(result[0] == (Char)65279) { result = result.Substring (1); }
return XDocument.Load (new StringReader (result)); }
where uri is a valid uri for an sdata value. e.g. "http://localhost:3333/sdata/slx/dynamic/contacts" I get 100 records only rather than all 1092 records in the slaeslogix_eval database.
It's the same for all entities accesible through SData only 100 records are returned
Any Ideas on how to get all of the records? Is this a known limitation of sData? Is this a configuration setting? The lack of documentation for working with sData is disturbing. Sales Logix goes on and on about how great this is, but doesn't provide any useful implentation guidance or documentation.
|
|
|
|
Re: sData not returning all of the data
Posted: 02 Jul 09 12:44 PM
|
I found out the answer!!
It seems that the data comes in 100 record pages.
To get all the records from a table you must page through the records using the ?SelectIndex= query argument
If using more than 1 argument use &SelectedIndex=i
where i is an incrementing integer variable declared in your code.
example:
string _baseUri = "http://server:port/sdata/slx/dynamic/contact?orderby=LastName"
create a credential cache object CredentialCache _webCredentials = new CredentialCache { { new Uri (_baseUri), "Digest", new NetworkCredential ("Admin", string.Empty) } };
//call this new static method I have implementted in a static helpers class so it is accesible throught a given namespace
XDocument document = GetXDocument(_webCredentials, _baseUri, atom namespace);
public static XDocument GetXDocument(CredentialCache webCredentials, string uri, XNamespace elementPrefix) { XDocument doc = new XDocument (); XDocument workingDoc = null; //page through the reords until all of them are returned int i = 1; bool isFinished = false; Uri requestUri = null; while(!isFinished) { //check to see if there is already a query argument in the uri if(uri.IndexOf("?") < 0) { //if not found in the string -1 is returned requestUri = new Uri (uri + "?StartIndex=" + i); } else { //an integr representing the location of the ? is returned and there is a query argument so append the argument requestUri = new Uri (uri + "&StartIndex=" + i); } WebRequest wreq = WebRequest.Create (requestUri); wreq.Credentials = webCredentials; workingDoc = XDocument.Load ( new StreamReader (wreq.GetResponse ().GetResponseStream())); if(workingDoc.Descendants(elementPrefix + "entry").Count() < 100 ) { isFinished = true; } if(i==1) { doc = workingDoc; } else { object[] contentArray = workingDoc.Descendants (elementPrefix + "entry").ToArray (); doc.Element (elementPrefix + "feed").Add (contentArray); } i++; } return doc; }
now work with the returnd XDocument to get the data you need to work with
More to come on this I'm sure...
|
|
|
|
Re: sData not returning all of the data
Posted: 27 Mar 12 11:15 AM
|
fiogf49gjkf0d For a quick and dirty way of getting around the 100 record limit, you can set the Count variable greater then 100 and get more records returned.
The Group I worked with had 391 contacts associated with it. Setting the Count to 1000 returned all 391 records in one pass.
snippet.....
...
...
var uri = new SDataUri("https://XXXXXXXX/sdata/slx/system/-/groups/$queries/execute")
{
Select = "*",
QueryArgs = { { "_groupId", "p6UJ9A0008IW" } },
StartIndex = 0,
Count = 1000
};
...
...
|
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|