Retrieving Items from a Picklist via Javascript using SData

Saleslogix is very light on how to use client side processes to do things in the Saleslogix web client.  I have decided to start to try to document snippets of things I find useful and make a repository of them.  The first one I am showing here is how to retrieve a list of picklist items using the client-side SData library.

In this code sample the items are returned in a plain list.

function getPicklistItems(picklistName) {
    var service = Sage.Data.SDataServiceRegistry.getSDataService('system');
    var request = new Sage.SData.Client.SDataResourceCollectionRequest(service)

    //var items = new Array();
    var items = [];
    request.setResourceKind('picklists');
    request.setQueryArg("where", "name eq '" + picklistName + "'");
    request.setQueryArg("include", "items");

    request.read({
        success: function (feed) {
            for (var i = 0; i < feed.$resources.length; i++) {
                var entry = feed.$resources[i];
                     
                for (var i2 = 0; i2 < entry.items.$resources.length; i2++) {
                    var item = entry.items.$resources[i2];                            
                    items.push(item.text);
                }
            }
            return items;
        },
        failure: function (feed) { }
    });            
    return items;
}
ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) news and product updates!

You have Successfully Subscribed!