back to top

Retrieving Data via SData for SalesLogix

If you followed my last two posts, you’ll know some basics of what SData is and how to get it to use in your projects. In this post, we will take this a step further and look at how to actually use it, starting with how to query data from SalesLogix.

View the SalesLogix SData Developer series index

Getting a list of Contacts

Let’s start with a basic query. For this example, we will retrieve all contacts whose last name starts with ‘Ab’. Take a look at the code (with comments to walk through each part)

using Sage.SData.Client.Core;
using Sage.SData.Client.Atom;
using Sage.SData.Client.Extensions;
//...
 
 
// All requests require an ISDataService which provides
// the service location and user authentication values
ISDataService svc =
    new SDataService("http://localhost/sdata/slx/dynamic/-/", "lee", "");
 
// Now create the request, passing in the ISDataService we created
// above
var req = new SDataResourceCollectionRequest(svc);
 
// Tell it which kind of resource we want to access, in this case
// Contacts. Note, this needs to match the values on the SData tab
// of the entity in Application Architect
req.ResourceKind = "Contacts";

// This part is optional (without it we'd be getting ALL contacts).
// This is our where clause, or condition of which contacts we want.
// In this example we want all contacts whose last name starts with
// the value 'Ab'. We need to use the exact property name as defined
// in the entity (case-sensitive).
req.QueryValues.Add("where", "LastName like 'Ab%'");
 
// Now read the data (or run the query)
AtomFeed feed = req.Read();
 
// We now have the results in our AtomFeed variable, which is
// basically a list of AtomEntry objects. To get to our data,
// we need to read the payload from each AtomEntry and then we
// can access the values for each field from it's Values
// dictionary. In this example, we'll just write a few fields
// from each contact to the console.
foreach (AtomEntry entry in feed.Entries)
{
    // Get the payload for this entity
    SDataPayload payload = entry.GetSDataPayload();
     
    // Now read some values from the payload. Note, the
    // property names you use here need to match the property
    // names defined for the entity (these are case-sensitive).
    string account = payload.Values["AccountName"].ToString();
    string contactName = payload.Values["NameLF"].ToString();
    string title = payload.Values["Title"].ToString();
     
    Console.WriteLine("{0}, {1} from {2}", contactName, account, title);
}

That’s not too bad. You do have to access the fields by string name, which means you don’t get intellisense, but at least it’s easy code to write. There are ways to retrieve the schema for an entity which I will look at in a future post.

View the SalesLogix SData Developer series index

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Ryan Farley
Ryan Farleyhttps://customerfx.com/article/author/ryanfarley/
Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

1 COMMENT

  1. Hi Ryan, here’s the documentation excerpt where i find the code:

    Handling Errors
    Normal Mode
    1. Construct an ISDataService passing in the SData provider URL
    ISDataService a = new SDataService(
    “http://localhost/sdata/aw/dynamic/-/”, “lee”, “”);
    NOTE: The URL can be passed in or the individual properties of the URL can be set.
    2. Construct a SDataSingleResourceRequests passing in the ISDataService
    var b = new SDataSingleResourceRequest(a);
    var c = new SDataSingleResourceRequest(a);
    var d = new SDataSingleResourceRequest(a);
    var e = new SDataSingleResourceRequest(a);
    3. Setup the Resource Selectors and payloads for create and update
    See – Create, Read, Update, Delete Single Resource
    4. Wrap the calls to Create, Read, Update and Delete in a try-catch block which catches exceptions of type SDataServiceException
    try
    {
    b.Create();
    c.Read();
    d.Update();
    e.Delete();
    }
    catch (SDataServiceException e)
    {
    string errorMessage = e.Diagnosis.Message;
    }

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Infor CRM SLX 10.0: Delegate Ownership Changes for “Everyone” Records

Learn how the new EveryoneOwnerAssignment secured action in Infor CRM SLX 10.0 allows designated users to change ownership of Everyone-owned records without requiring Administrator access.

Related Articles

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Related Videos