{"id":820,"date":"2012-09-19T17:58:55","date_gmt":"2012-09-19T17:58:55","guid":{"rendered":"http:\/\/mahenderpal.wordpress.com\/?p=820"},"modified":"2012-09-19T17:58:55","modified_gmt":"2012-09-19T17:58:55","slug":"working-with-ms-crm-2011-data-types","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=820","title":{"rendered":"Working with MS CRM 2011 data types"},"content":{"rendered":"<p>I have seen many question in <a href=\"http:\/\/social.microsoft.com\/Forums\/en-IN\/crmdevelopment\/threads\">MS CRM Development <\/a>where developers asking for MS CRM 2011 data type related question, like how to set lookup field, how to set\/retrieve optionset value. so I thought to write code to show how we can set different data type field in MS CRM 2011.<\/p>\n<p>Below is the example to create account using late bound<\/p>\n<p>Entity _Account = new Entity();<br \/>\n_Account.LogicalName = &#8220;account&#8221;;<br \/>\n\/\/setting text field<br \/>\n_Account.Attributes.Add(&#8220;name&#8221;, &#8220;Myaccount123&#8221;);<\/p>\n<p>\/\/setting optionset field<br \/>\n_Account.Attributes.Add(&#8220;accountcategorycode&#8221;, new OptionSetValue(2));<\/p>\n<p>\/\/setting datetime field<br \/>\n_Account.Attributes.Add(&#8220;new_collectiondate&#8221;, new DateTime(2012, 3, 25));<\/p>\n<p>\/\/setting currency field<br \/>\n_Account.Attributes.Add(&#8220;creditlimit&#8221;, new Money(300));<\/p>\n<p>\/\/setting lookup<br \/>\n_Account.Attributes.Add(&#8220;parentaccountid&#8221;, new EntityReference(&#8220;account&#8221;, new Guid(&#8220;XXX-XXX&#8230;&#8230;..&#8221;)));<\/p>\n<p>\/\/setting decimal<br \/>\n_Account.Attributes.Add(&#8220;new_executivecommission&#8221;, new Decimal(55.5));<\/p>\n<p>\/\/setting boolean<br \/>\n_Account.Attributes.Add(&#8220;new_isbilled&#8221;, true);<\/p>\n<p>service.Create(_Account);<\/p>\n<p>we should get new account created like below<\/p>\n<p><a href=\"http:\/\/mahenderpal.files.wordpress.com\/2012\/09\/account.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-822\" title=\"account\" src=\"http:\/\/mahenderpal.files.wordpress.com\/2012\/09\/account.png?w=300\" alt=\"\" width=\"300\" height=\"170\" \/><\/a><\/p>\n<p>In next post I will show how to retrieve different data types fields using server side code.<\/p>\n<p>Enjoy !!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have seen many question in MS CRM Development where developers asking for MS CRM 2011 data type related question, like how to set lookup field, how to set\/retrieve optionset value. so I thought to write code to show how we can set different data type field in MS CRM 2011. Below is the example to create account using late&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=820\">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":[5],"tags":[94,107,109],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/820"}],"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=820"}],"version-history":[{"count":0,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/820\/revisions"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=820"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}