10-21-2011 07:56 AM
I am trying to retrieve a list of picklist items using the SDATA REST API. Have tried using the format http://10.0.0.66:3333/sdata/slx/system/-/pickLists('kSYST0000386')?format=xml to bring back a list of cities but it just returns
<sdataayload>
<slxickList sdata:key="kSYST0000312" sdata:uri="http://10.0.0.66:3333/sdata/slx/system/-/pickLists('kSYST0000312')" sdata:lookup="http://10.0.0.66:3333/sdata/slx/system/-/pickLists">
<slx:name>Opportunity Product Status</slx:name>
<slx:allowMultiples>false</slx:allowMultiples>
<slx:valueMustExist>false</slx:valueMustExist>
<slx:required>false</slx:required>
<slx:alphaSorted>false</slx:alphaSorted>
<slx:noneEditable>false</slx:noneEditable>
<slx:createDate>2009-10-06T00:00:38+01:00</slx:createDate>
<slx:createUser xsi:nil="true" />
<slx:modifyDate>2009-10-06T00:00:38+01:00</slx:modifyDate>
<slx:modifyUser xsi:nil="true" />
<slx:items />
</slxickList>
</sdataayload>
with no data. Has anybody managed to do this?
10-21-2011 07:57 AM
Wrong payload it was:
<sdataayload>
<slxickList sdata:key="kSYST0000386" sdata:uri="http://10.0.0.66:3333/sdata/slx/system/-/pickLists('kSYST0000386')" sdata:lookup="http://10.0.0.66:3333/sdata/slx/system/-/pickLists">
<slx:name>City</slx:name>
<slx:allowMultiples>false</slx:allowMultiples>
<slx:valueMustExist>false</slx:valueMustExist>
<slx:required>false</slx:required>
<slx:alphaSorted>true</slx:alphaSorted>
<slx:noneEditable>false</slx:noneEditable>
<slx:createDate>2009-10-06T00:00:38+01:00</slx:createDate>
<slx:createUser xsi:nil="true" />
<slx:modifyDate>2009-10-06T00:00:38+01:00</slx:modifyDate>
<slx:modifyUser xsi:nil="true" />
<slx:items />
</slxickList>
</sdataayload>
10-27-2011 11:51 PM
You are looking for the items collection.
Try the following:
http://10.0.0.66:3333/sdata/slx/system/-/pickLists('kSYST0000386')/items?format=xml
Notice that I appended "/items" to the URL to retreive the items collection.
10-28-2011 12:44 AM
To clarify:
This URL only brings the Picklist Items
http://10.0.0.66:3333/sdata/slx/system/-/pickLists('kSYST0000386')/items?format=xml
This URL brings down the Picklist and its items:
http://crmbisvr08:3333/sdata/slx/system/-/pickLists('k6UJ9A0003DN')?include=$children&format=xml
10-28-2011 07:34 AM
Or you could do this in .Net
private void LoadPickList(string pklName, ComboBox cboName) { //Create the actually SData call SDataService service = new SDataService(_url + "/sdata/slx/system/-/", _user, _password); SDataResourceCollectionRequest sdataCollection = new SDataResourceCollectionRequest(service) { ResourceKind = "pickLists", QueryValues = { {"where", "name eq '" + pklName + "'"}, {"include", "items"} }, }; AtomFeed feed = sdataCollection.Read(); DataTable table = new DataTable(); table.Columns.Add("itemId"); table.Columns.Add("itemText"); foreach (AtomEntry tempEntry in feed.Entries) { SDataPayload pickList = (SDataPayload)tempEntry.GetSDataPayload(); SDataPayloadCollection pickListItems = (SDataPayloadCollection)pickList.Values["items"]; foreach (SDataPayload p in pickListItems) { DataRow dr = table.NewRow(); dr["itemId"] = p.Key; dr["itemText"] = p.Values["text"]; table.Rows.Add(dr); } } cboName.DataSource = table; cboName.DisplayMember = "itemText"; cboName.ValueMember = "itemId"; }