{"id":27148,"date":"2021-03-06T10:19:44","date_gmt":"2021-03-06T10:19:44","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=27148"},"modified":"2021-03-06T10:19:44","modified_gmt":"2021-03-06T10:19:44","slug":"format-input-values-using-formatting-api-in-pcf-control-within-dynamics-365-crm","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2021\/03\/format-input-values-using-formatting-api-in-pcf-control-within-dynamics-365-crm\/","title":{"rendered":"Format input values using Formatting API in PCF Control within Dynamics 365 CRM"},"content":{"rendered":"<p>In our past projects, we created a PCF Control in which we had a requirement to format the input values like strings\/numbers to the user currency\/decimal format according to the user personalized settings set in Dynamics 365 CRM. To achieve this, we used a new Formatting API of Power Apps. This API makes our code very simple, we do not need to do any more coding or tweaks to make the values in proper user format.<\/p>\n<p>Please find the example below, we have set the user settings as Italian (Italy).<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/1-Format-input-values-using-Formatting-API-in-PCF-Control-2.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-27154 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/1-Format-input-values-using-Formatting-API-in-PCF-Control-2.png\" alt=\"Formatting API in PCF Control\" width=\"1023\" height=\"618\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/1-Format-input-values-using-Formatting-API-in-PCF-Control-2.png 1023w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/1-Format-input-values-using-Formatting-API-in-PCF-Control-2-300x181.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/1-Format-input-values-using-Formatting-API-in-PCF-Control-2-768x464.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/1-Format-input-values-using-Formatting-API-in-PCF-Control-2-660x399.png 660w\" sizes=\"(max-width: 1023px) 100vw, 1023px\" \/><\/a><br \/>\nIn the code below, we have written the code to format the input values in our PCF Control:<\/p>\n<p>\/\/Function that return result in user currency format from input value<br \/>\nformatToCurrency(context: ComponentFramework.Context&lt;IInputs&gt;, inputValue:any) {<br \/>\nreturn context.formatting.formatCurrency(inputValue);<br \/>\n}<\/p>\n<p>\/\/Function that return result in user decimal format from input value<br \/>\nformatToDecimal(context: ComponentFramework.Context&lt;IInputs&gt;, inputValue:any) {<br \/>\nreturn context.formatting.formatDecimal(inputValue);<br \/>\n}<\/p>\n<p>Please find the screenshot below where we have run the debugger to see the result of the format of input values to user format i.e. Italian (Italy).<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/2-Format-input-values-using-Formatting-API-in-PCF-Control-2.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-27155 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/2-Format-input-values-using-Formatting-API-in-PCF-Control-2.png\" alt=\"\" width=\"804\" height=\"235\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/2-Format-input-values-using-Formatting-API-in-PCF-Control-2.png 804w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/2-Format-input-values-using-Formatting-API-in-PCF-Control-2-300x88.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/2-Format-input-values-using-Formatting-API-in-PCF-Control-2-768x224.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/2-Format-input-values-using-Formatting-API-in-PCF-Control-2-660x193.png 660w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><\/a><\/p>\n<p>Conclusion:<\/p>\n<p>With the help of the Formatting API of Power Apps, we can easily format the input values for the login user format.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/product\/productivity-apps\/automated-recurring-billing-invoicing-dynamics-365-crm\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-27156 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/recurring-billing.jpg\" alt=\"\" width=\"800\" height=\"200\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/recurring-billing.jpg 800w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/recurring-billing-300x75.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/recurring-billing-768x192.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/recurring-billing-660x165.jpg 660w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our past projects, we created a PCF Control in which we had a requirement to format the input values like strings\/numbers to the user currency\/decimal format according to the user personalized settings set in Dynamics 365 CRM. To achieve this, we used a new Formatting API of Power Apps. This API makes our code\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2021\/03\/format-input-values-using-formatting-api-in-pcf-control-within-dynamics-365-crm\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"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":[16,19,1929],"tags":[545,592,2191,1941,1337],"class_list":["post-27148","post","type-post","status-publish","format-standard","hentry","category-dynamics-365","category-dynamics-crm","category-pcf","tag-dynamics-365-crm","tag-dynamics-crm","tag-format-input-values","tag-pcf-control","tag-power-apps"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/27148","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=27148"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/27148\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=27148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=27148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=27148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}