Sdata is the tool of choice when it comes to integrating with SalesLogix and soon most of the products Sage owns. Here are a few examples of working with group information. Keep a lookout for a full example
So once a user logs into SalesLogix via an Sdata service context has been astablished. This means any records that the logged in user has access to can be manipulated but this does not stop there. Only the groups that user has access to can be accessed as well. Below is a method that would return all the groups a user has access to from within a specific group family.
private void LoadGroups(string FamilyName) { //Create the actually SData call SDataService service = new SDataService(txtServer.Text + ":" + txtPort.Text + "/sdata/slx/system/-/",txtUserName.Text,txtPassword.Text); SDataResourceCollectionRequest sdataCollection = new SDataResourceCollectionRequest(service) { ResourceKind = "groups", QueryValues = { {"where", "family eq '" + FamilyName + "'"} }, }; AtomFeed feed = sdataCollection.Read(); cboGroups.Text = ""; cboGroups.Items.Clear(); foreach (AtomEntry tempEntry in feed.Entries) { SDataPayload group = (SDataPayload)tempEntry.GetSDataPayload(); cboGroups.Items.Add(new MyListItems { Display = group.Values["name"].ToString(), Value = group.Key }); cboGroups.DisplayMember = "Display"; } }
A few things to note here...
1. Notice that the URL is different then what you might be expecting. You need to direct you request to the "SYSTEM" endpoint.
2. As you can see you simply just pass the family name to this Sdata call which in turn gives you a collection of groups the user can access.
3. I'm using a custom class called "MyListItems" to store some of the group data that is returned but you can do what ever you like with it.
4. Important to note that you now have the group id's. You can now pass those id's to another call which will return even more information. Let's check that out now
This next call is really cool! It will return the layout information of a group. So what this means is pretty much all the metadata of the group. Fields, column width, types and pretty much all the cool stuff you would want to know about a group's layout. Here is a snippet of code that grabs all the fields in a group layout.
private void LoadFieldNames() { MyListItems group = (MyListItems)cboGroups.SelectedItem; var request = new SDataRequest("http://localhost:3333/sdata/slx/system/-/groups('" + group.Value + "')?include=layout") { UserName = "admin" }; var response = request.GetResponse(); var entry = (AtomEntry)response.Content; SDataPayload groupPayload = entry.GetSDataPayload(); SDataPayloadCollection layoutCollection = (SDataPayloadCollection)groupPayload.Values["layout"]; ckblGroupFields.Items.Clear(); foreach (SDataPayload pl in layoutCollection) { if (!String.IsNullOrEmpty(pl.Values["caption"].ToString())) { ckblGroupFields.Items.Add(new MyListItems { Display = pl.Values["caption"].ToString(), Value = pl.Values["alias"].ToString() }); } } ckblGroupFields.DisplayMember = "Display"; }
Again some points to note here...
1. Just like above the endpoint is to the "SYSTEM" endpoint.
2. The call is pretty simple, just pass the id of the group and the group is returned. Not to much different than calling an account or any other entity.
Hope these are useful to you! Stay tuned for a full example that exports data via groups (example is pretty much built, just needs some cleanup hahaha)