{"id":6751,"date":"2017-10-13T17:35:27","date_gmt":"2017-10-13T12:05:27","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=6751"},"modified":"2017-10-13T17:35:27","modified_gmt":"2017-10-13T12:05:27","slug":"reading-set-personal-options-user-settings-and-applying-it-on-number-and-currency-datatype-fields","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2017\/10\/reading-set-personal-options-user-settings-and-applying-it-on-number-and-currency-datatype-fields\/","title":{"rendered":"Reading \u2018Set Personal Options\u2019 user settings and applying it on Number and Currency Datatype Fields"},"content":{"rendered":"<h3 style=\"text-align: justify;\"><strong>Introduction:<\/strong><\/h3>\n<p style=\"text-align: justify;\">Microsoft Dynamics 365 allows the user to customize the formatting of <em>Number, Currency, Date and Time<\/em> datatype fields that are used on Entity Forms (<em>For example, Annual Revenue field on the Account entity form<\/em>).<\/p>\n<h3 style=\"text-align: justify;\"><strong>Formatting the Number and Currency datatype fields:<\/strong><\/h3>\n<p style=\"text-align: justify;\">The user can format the datatype fields by simply navigating to <strong><em>Settings &gt; Options &gt; Formats &gt; Customize <\/em><\/strong>and set the required values for the datatypes.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/10\/1.png\"><img decoding=\"async\" class=\"wp-image-6759 aligncenter\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/10\/1.png\" alt=\"Reading \u2018Set Personal Options\u2019 user settings and applying it on Number and Currency Datatype Fields\" width=\"443\" height=\"380\" \/><\/a>After this, all the fields will be formatted based on the values selected in the <em>\u2018Format\u2019<\/em> tab for Number, Currency fields on the entity form.<\/p>\n<p style=\"text-align: justify;\">So based on the values selected in the above screenshot, the <em>Annual Revenue (Currency)<\/em> &amp; <em>No. of Employees (Number)<\/em> fields on the Account entity form would look like the screenshot below;<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/10\/2.png\"><img decoding=\"async\" class=\"size-full wp-image-6760 aligncenter\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/10\/2.png\" alt=\"Reading \u2018Set Personal Options\u2019 user settings and applying it on Number and Currency Datatype Fields\" width=\"268\" height=\"93\" \/><\/a>The formatting will be reflected on all the fields of the entities in Dynamics CRM.<\/p>\n<h3><strong>Reading \u2018Set Personal Options\u2019 user settings and applying it on Number and Currency Datatype Fields:<\/strong><\/h3>\n<p>Recently, we had a business requirement to show a <em>\u2018Sum\u2019<\/em> button that on clicking would pop an <em>\u2018<\/em><em>HTML Card\u2019<\/em> with sum of the <em>\u2018Annual Revenue\u2019<\/em> for all the records fulfilling certain criteria.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/10\/3.png\"><img decoding=\"async\" class=\"size-full wp-image-6761 aligncenter\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/10\/3.png\" alt=\"Reading \u2018Set Personal Options\u2019 user settings and applying it on Number and Currency Datatype Fields\" width=\"271\" height=\"106\" \/><\/a>However, as seen from the above screenshot, the formatting we applied (<em>Decimal Symbol &amp; Digit Grouping Symbol<\/em>) for <em>\u2018Annual Revenue\u2019<\/em> and <em>\u2018No. of Employees\u2019<\/em> was not reflected on the card.<\/p>\n<p style=\"text-align: justify;\">So, we found a workaround, where we read the user\u2019s <em>\u2018Set Personal Options\u2019<\/em> setting and dynamically apply it on our HTML Card.<\/p>\n<p style=\"text-align: justify;\">Now, when the user changes the <em>\u2018Set Personal Options\u2019<\/em> setting, the formatting pattern would be reflected on the fields just like it would reflect on the fields (<em>Annual Revenue &amp; No. of Employees<\/em>) available on the entity form.<\/p>\n<p style=\"text-align: justify;\">To achieve this we need to follow the steps mentioned below:<\/p>\n<p style=\"text-align: justify;\">We need to include all the attributes that we want to retrieve from <em>\u2018User Settings\u2019<\/em> entity in our FetchXML.<\/p>\n<p style=\"text-align: justify;\">In our case, we included the following attributes;<\/p>\n<ul>\n<li style=\"text-align: justify;\">currencysymbol<\/li>\n<li style=\"text-align: justify;\">numberseparator<\/li>\n<li style=\"text-align: justify;\">decimalsymbol<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true \">function readUserDateFormat ()\n {\n    var functionName = \"readUserDateFormat \";\n    var fetchxml = \"\";\n    var results = null;\n    var currentUser = Xrm.Page.context.getUserId();\n    var userID = currentUser.replace(\"{\", \"\").replace(\"}\", \"\");\n   \n\n        \/\/generate the fetchxml\n        fetchxml = \"&lt;fetch version='1.0' output-format='xml-platform' mapping='logical' \t\tdistinct='false'&gt;\";\n        fetchxml += \"&lt;entity name='usersettings'&gt;\";\n        fetchxml += \"&lt;attribute name='dateformatstring' \/&gt;\";\n        fetchxml += \"&lt;attribute name='dateseparator' \/&gt;\";\n        fetchxml += \"&lt;attribute name='uilanguageid' \/&gt;\";\n        fetchxml += \"&lt;attribute name='decimalsymbol' \/&gt;\";\n        fetchxml += \"&lt;attribute name='numberseparator' \/&gt;\";\n        fetchxml += \"&lt;attribute name='currencysymbol' \/&gt;\";\n        fetchxml += \"&lt;filter&gt;\";\n        fetchxml += \"&lt;condition attribute='systemuserid' operator='eq' value='\" + userID + \"' \/&gt;\";\n        fetchxml += \"&lt;\/filter&gt;\";\n        fetchxml += \"&lt;\/entity&gt;&lt;\/fetch&gt;\";\n        \n}<\/pre>\n<p style=\"text-align: justify;\">Once we execute the above FetchXML using Web API, we get the following result;<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/10\/4.png\"><img decoding=\"async\" class=\" wp-image-6762 aligncenter\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/10\/4.png\" alt=\"Reading \u2018Set Personal Options\u2019 user settings and applying it on Number and Currency Datatype Fields4\" width=\"636\" height=\"286\" \/><\/a>In the above result response, we can see that by querying <em>\u2018User Settings\u2019<\/em> entity with the attributes (<em>currencysymbol, numberseparator, decimalsymbol<\/em>), we get the values set for those attributes\u00a0using <em>\u2018Set Personal Options\u2019<\/em> by that particular user.<\/p>\n<p style=\"text-align: justify;\">Once we retrieve the user settings, we can modify our code to use these values and format the Number &amp; Currency fields.<\/p>\n<p style=\"text-align: justify;\">Now our HTML Card would look like the screenshot below;<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/10\/5.png\"><img decoding=\"async\" class=\"size-full wp-image-6763 aligncenter\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/10\/5.png\" alt=\"Reading \u2018Set Personal Options\u2019 user settings and applying it on Number and Currency Datatype Fields\" width=\"336\" height=\"106\" \/><\/a><\/p>\n<h3 style=\"text-align: justify;\"><strong>Conclusion:<\/strong><\/h3>\n<p style=\"text-align: justify;\">We can use the <em>\u2018User Settings\u2019<\/em> entity along with the attribute names to retrieve the personalization settings configured by the user and display consistent formatting throughout Dynamics CRM.<\/p>\n<p><a href=\"http:\/\/www.inogic.com\/product\/integrations\/inolink-quickbooks-microsoft-dynamics-crm\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-6770 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/10\/Get-started-with-QuickBooks-and-Dynamics-365-Integration.png\" alt=\"Get started with QuickBooks and Dynamics 365 Integration\" width=\"800\" height=\"200\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: Microsoft Dynamics 365 allows the user to customize the formatting of Number, Currency, Date and Time datatype fields that are used on Entity Forms (For example, Annual Revenue field on the Account entity form). Formatting the Number and Currency datatype fields: The user can format the datatype fields by simply navigating to Settings &gt;\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2017\/10\/reading-set-personal-options-user-settings-and-applying-it-on-number-and-currency-datatype-fields\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":6756,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[13,16,19,65],"tags":[439],"class_list":["post-6751","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-customizations","category-dynamics-365","category-dynamics-crm","category-webapi","tag-currency-datatype-fields"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/6751","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=6751"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/6751\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/6756"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=6751"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=6751"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=6751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}