{"id":971,"date":"2013-04-10T16:05:03","date_gmt":"2013-04-10T16:05:03","guid":{"rendered":"http:\/\/mahenderpal.wordpress.com\/?p=971"},"modified":"2013-04-10T16:05:03","modified_gmt":"2013-04-10T16:05:03","slug":"getting-crm-user-date-and-time-format-setting-in-silverlight-microsoft-crm-2011","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=971","title":{"rendered":"Getting CRM User Date and Time Format Setting in Silverlight Microsoft CRM 2011"},"content":{"rendered":"<p>If you are working with Silverlight web resource and you need to get current crm user date time format then you can query usersettings entity and get datetime format setting for user. I have used <a href=\"http:\/\/silvercrmsoap.codeplex.com\/\">Silvercrmsaop <\/a>library in my project. You can use below code for the same:<\/p>\n<p>public void RetrieveUserSettingRecord(Guid _UserID)<br \/>\n{<br \/>\ntry<br \/>\n{<br \/>\nthis._d.BeginInvoke(delegate()<br \/>\n{<br \/>\nEntityReference EntityID = new EntityReference();<br \/>\nEntityID.Id = _UserID;<br \/>\nEntityID.LogicalName = &#8220;usersettings&#8221;;<br \/>\nOrganizationRequest request = new OrganizationRequest() { RequestName = &#8220;Retrieve&#8221; };<br \/>\nrequest[&#8220;Target&#8221;] = EntityID;<br \/>\nColumnSet columns = new ColumnSet();<br \/>\ncolumns.Columns = new System.Collections.ObjectModel.ObservableCollection&lt;string&gt;(new string[] { &#8220;dateformatstring&#8221;, &#8220;timeformatstring&#8221; });<br \/>\nrequest[&#8220;ColumnSet&#8221;] = columns;<br \/>\nIOrganizationService service = SilverlightUtility.GetSoapService();<br \/>\n\/\/send the async request and specify it&#8217;s callback<br \/>\nservice.BeginExecute(request, new AsyncCallback(RetrieveCurrentUserSetting), service);<\/p>\n<p>});<\/p>\n<p>}<br \/>\ncatch (Exception ex)<br \/>\n{<br \/>\nthrow ex;<br \/>\n}<\/p>\n<p>}<\/p>\n<p>private void RetrieveCurrentUserSetting(IAsyncResult result)<br \/>\n{<br \/>\ntry{<\/p>\n<p>this._d.BeginInvoke(delegate()<br \/>\n{<br \/>\nOrganizationResponse Response = ((IOrganizationService)result.AsyncState).EndExecute(result);<br \/>\nSilverCrmSoap.CrmSdk.Entity _SystemUser = (SilverCrmSoap.CrmSdk.Entity)Response[&#8220;Entity&#8221;];<br \/>\nif (_SystemUser.GetAttributeValue&lt;string&gt;(&#8220;dateformatstring&#8221;) != null)<br \/>\n{<br \/>\nstring DateformatString = _SystemUser.GetAttributeValue&lt;string&gt;(&#8220;dateformatstring&#8221;);<br \/>\n}<br \/>\nif (_SystemUser.GetAttributeValue&lt;string&gt;(&#8220;timeformatstring&#8221;) != null)<br \/>\n{<br \/>\nstring TimeFormatString = _SystemUser.GetAttributeValue&lt;string&gt;(&#8220;timeformatstring&#8221;);<\/p>\n<p>}<br \/>\n});<br \/>\n}<br \/>\ncatch (Exception ex)<br \/>\n{<br \/>\nthrow ex;<br \/>\n}<\/p>\n<p>}<\/p>\n<p>Hope it will help someone !!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are working with Silverlight web resource and you need to get current crm user date time format then you can query usersettings entity and get datetime format setting for user. I have used Silvercrmsaop library in my project. You can use below code for the same: public void RetrieveUserSettingRecord(Guid _UserID) { try { this._d.BeginInvoke(delegate() { EntityReference EntityID =&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=971\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[51,52,199],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/971"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=971"}],"version-history":[{"count":0,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/971\/revisions"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}