Quantcast
Channel: CRM Development Forum
Viewing all articles
Browse latest Browse all 888

ms crm 2011 - how to get the option set's selected value in oData Query using SDK.REST Services?

$
0
0

    Hi

Following is the code which I wrote for accessing the selected option set's value for a particular record. But I am not getting the object's value.

Can anyone let me know how to get the text values(Labels) for the selected option sets, please.

<title>Test</title><script src="../ClientGlobalContext.js.aspx" type="text/javascript"><script src="Scripts/jquery1.4.1.min.js" type="text/javascript"></telerik:script><script src="Scripts/json2.js" type="text/javascript">&lt;/telerik:script&gt;Hi Everyone,&lt;/p&gt;&lt;p&gt;I am using following SDK.REST call for getting the option set text value, which is selected for the Account record.&lt;/p&gt;&lt;script type="text/javascript"&gt;if (typeof (NS) == "undefined") { NS = { _namespace: true }; } NS.CATEGORY = { getRESTUrl: function () { ///&amp;lt;summary&amp;gt; /// Returns a valid URL for REST endpoint requests. ///&amp;lt;/summary&amp;gt; var RESTServicePath = "/xrmservices/2011/organizationdata.svc"; var serverUrl = ""; if (typeof GetGlobalContext == "function") { var context = GetGlobalContext(); serverUrl = context.getServerUrl(); } else { if (typeof Xrm.Page.context == "object") { serverUrl = Xrm.Page.context.getServerUrl(); } else { throw new Error("Unable to access the server URL"); } } if (serverUrl.match(/\/$/)) { serverUrl = serverUrl.substring(0, serverUrl.length - 1); } return serverUrl + RESTServicePath; }, errorHandler: function () { alert("Error"); }, getOptions: function () { SDK.REST.retrieveMultipleRecords("Account","$select=Address1_AddressTypeCode,ShippingMethodCode", function (results) { flag = 0; fieldAttribute = results[0]; if (fieldAttribute != null) { alert(fieldAttribute.Address1_AddressTypeCode); } else { alert("error"); } }, NS.CATEGORY.errorHandler, function () { }); }, _namespace: true }; NS.CATEGORY.getOptions(); </script></script>

<html><head><title>Test</title><script type="text/javascript" src="../ClientGlobalContext.js.aspx"></script><script type="text/javascript" src="Scripts/SDK.RestEndpointPaging.js"></script><script type="text/javascript" src="scripts/SDK.REST.js"></script><script type="text/javascript" src="Scripts/jquery1.4.1.min.js"></script><script type="text/javascript" src="Scripts/json2.js"></script><script type="text/javascript">
        if (typeof (NS) == "undefined")
        { NS = { _namespace: true }; }
        NS.CATEGORY = {
            getRESTUrl: function () {
                ///<summary>
                /// Returns a valid URL for REST endpoint requests.
                ///</summary>
                var RESTServicePath = "/xrmservices/2011/organizationdata.svc";
                var serverUrl = "";
                if (typeof GetGlobalContext == "function") {
                    var context = GetGlobalContext();
                    serverUrl = context.getServerUrl();
                }
                else {
                    if (typeof Xrm.Page.context == "object") {
                        serverUrl = Xrm.Page.context.getServerUrl();
                    }
                    else
                    { throw new Error("Unable to access the server URL"); }
                }
                if (serverUrl.match(/\/$/)) {
                    serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                }
                return serverUrl + RESTServicePath;
            },
            errorHandler: function () {
                alert("Error");
            },
            getOptions: function () {
                SDK.REST.retrieveMultipleRecords("Account", "$select=Address1_AddressTypeCode,ShippingMethodCode", function (results) {
                    flag = 0;
                    fieldAttribute = results[0];
                    if (fieldAttribute != null) {
                        alert(fieldAttribute.Address1_AddressTypeCode);
                    }
                    else {
                        alert("error");
                    }
                },
            NS.CATEGORY.errorHandler,
            function () {
            });
            },

            _namespace: true
        };

        NS.CATEGORY.getOptions();
        
    </script></head><body></body></html>

Thanks,


Rajeev


Viewing all articles
Browse latest Browse all 888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>