{"id":32336,"date":"2022-08-04T13:00:49","date_gmt":"2022-08-04T07:30:49","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=32336"},"modified":"2022-08-04T13:00:49","modified_gmt":"2022-08-04T07:30:49","slug":"format-input-values-into-different-user-input-formats-using-formatting-api-in-pcf-control","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2022\/08\/format-input-values-into-different-user-input-formats-using-formatting-api-in-pcf-control\/","title":{"rendered":"Format input values into different user input formats using Formatting API in PCF Control"},"content":{"rendered":"<p><strong>Introduction<\/strong><\/p>\n<p>In the previous <a href=\"https:\/\/www.inogic.com\/blog\/2021\/03\/format-input-values-using-formatting-api-in-pcf-control-within-dynamics-365-crm\/\" target=\"_blank\" rel=\"noopener\">blog<\/a>, we have explained the Formatting API of PCF Control where we used the Formatting API to format the input values.<\/p>\n<p>Earlier, we used different Formatting API methods to format the <a href=\"https:\/\/docs.microsoft.com\/en-us\/power-apps\/developer\/component-framework\/reference\/formatting\/formatdecimal\" target=\"_blank\" rel=\"noopener\">number<\/a> and <a href=\"https:\/\/docs.microsoft.com\/en-us\/power-apps\/developer\/component-framework\/reference\/formatting\/formattime\" target=\"_blank\" rel=\"noopener\">date<\/a> values. In this blog, we will introduce a new Formatting API method (<a href=\"https:\/\/docs.microsoft.com\/en-us\/power-apps\/developer\/component-framework\/reference\/formatting\/formatuserinput\" target=\"_blank\" rel=\"noopener\">formatUserInput<\/a>) that formats the given input values in different user input formats.<\/p>\n<p>In the below example, we have set the user settings as Number with 2 precision:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-32337\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/1Formatting-API-in-PCF-Control.jpeg\" alt=\"Formatting API in PCF Control\" width=\"945\" height=\"438\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/1Formatting-API-in-PCF-Control.jpeg 945w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/1Formatting-API-in-PCF-Control-300x139.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/1Formatting-API-in-PCF-Control-768x356.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/1Formatting-API-in-PCF-Control-660x306.jpeg 660w\" sizes=\"(max-width: 945px) 100vw, 945px\" \/><\/p>\n<p>Given below are the two (Decimal Number) examples, where in the first example, the input value format to the user format is defined in user settings of Dynamics 365 CRM. And in the second example, the input value format to the user input format is passed as a input parameter to Formatting API method (<a href=\"https:\/\/docs.microsoft.com\/en-us\/power-apps\/developer\/component-framework\/reference\/formatting\/formatuserinput\" target=\"_blank\" rel=\"noopener\">formatUserInput<\/a>).<\/p>\n<pre class=\"lang:css gutter:true start:1\">\/\/Function that return result in user decimal format from input value\r\n\r\nformatToDecimal(context:\u00a0ComponentFramework.Context&lt;IInputs&gt;,\u00a0inputValue:any)\u00a0{\r\n\r\nreturn\u00a0context.formatting.formatDecimal(inputValue);\r\n\r\n}\r\n\r\n\/\/Function that return result in decimal format that passed in user input type\r\n\r\nformatToInputType(context: ComponentFramework.Context&lt;IInputs&gt;, inputValue:any): any {\r\n\r\nlet userInputType = {\r\n\r\nType: \"decimal\",\r\n\r\nPrecision: 4,\r\n\r\nPrecisionSource: 0,\r\n\r\nBehavior: null,\r\n\r\nOptionSet: null,\r\n\r\nFormat: null\r\n\r\n};\r\n\r\nreturn context.formatting.formatUserInput(inputValue, userInputType);\r\n\r\n}<\/pre>\n<p>In the below screenshot, you will find here that we have run the debugger to see the result of the format of input values:<br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-32338\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/2Formatting-API-in-PCF-Control.jpeg\" alt=\"Formatting API in PCF Control\" width=\"405\" height=\"268\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/2Formatting-API-in-PCF-Control.jpeg 405w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/2Formatting-API-in-PCF-Control-300x199.jpeg 300w\" sizes=\"(max-width: 405px) 100vw, 405px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>With the help of Formatting API of Power Apps, we can easily format the input values to different user input format.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/product\/productivity-apps\/click-2-clone-microsoft-dynamics-crm-records\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"alignnone  wp-image-32340\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/1-1.jpg\" alt=\"\" width=\"844\" height=\"211\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/1-1.jpg 800w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/1-1-300x75.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/1-1-768x192.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/08\/1-1-660x165.jpg 660w\" sizes=\"(max-width: 844px) 100vw, 844px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In the previous blog, we have explained the Formatting API of PCF Control where we used the Formatting API to format the input values. Earlier, we used different Formatting API methods to format the number and date values. In this blog, we will introduce a new Formatting API method (formatUserInput) that formats the given\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2022\/08\/format-input-values-into-different-user-input-formats-using-formatting-api-in-pcf-control\/\">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":[18,44,1929,2361],"tags":[],"class_list":["post-32336","post","type-post","status-publish","format-standard","hentry","category-dynamics-365-v9-2","category-power-apps","category-pcf","category-technical"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/32336","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=32336"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/32336\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=32336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=32336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=32336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}