Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, April 19, 2024 
 
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!
 Web Forums - ASP/ASP.NET/Web Services/Other
Forum to discuss building external web applications for SalesLogix. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to ASP/ASP.NET/Web Services/Other | New ThreadView:  Search:  
 Author  Thread: sData not returning all of the data
Terry
Posts: 14
 
sData not returning all of the dataYour last visit to this thread was on 1/1/1970 12:00:00 AM
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.

[Reply][Quote]
Terry
Posts: 14
 
Re: sData not returning all of the dataYour last visit to this thread was on 1/1/1970 12:00:00 AM
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...
[Reply][Quote]
Jeff L
Posts: 65
 
Re: sData not returning all of the dataYour last visit to this thread was on 1/1/1970 12:00:00 AM
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


 


            };


...


...


[Reply][Quote]
 Page 1 of 1 
  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!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 4/19/2024 2:24:03 PM