Format input values Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/format-input-values/ Microsoft Dynamics CRM . Microsoft Power Platform Sat, 06 Mar 2021 10:19:44 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.1 https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/cropped-Microsoftdynamics365-blogs.png?fit=32%2C32 Format input values Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/format-input-values/ 32 32 176351444 Format input values using Formatting API in PCF Control within Dynamics 365 CRM http://microsoftdynamics.in/2021/03/06/format-input-values-using-formatting-api-in-pcf-control-within-dynamics-365-crm/ Sat, 06 Mar 2021 10:19:44 +0000 https://www.inogic.com/blog/?p=27148 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...

The post Format input values using Formatting API in PCF Control within Dynamics 365 CRM appeared first on Microsoft Dynamics 365 Blog.

]]>
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.

Please find the example below, we have set the user settings as Italian (Italy).

Formatting API in PCF Control
In the code below, we have written the code to format the input values in our PCF Control:

//Function that return result in user currency format from input value
formatToCurrency(context: ComponentFramework.Context<IInputs>, inputValue:any) {
return context.formatting.formatCurrency(inputValue);
}

//Function that return result in user decimal format from input value
formatToDecimal(context: ComponentFramework.Context<IInputs>, inputValue:any) {
return context.formatting.formatDecimal(inputValue);
}

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).

Conclusion:

With the help of the Formatting API of Power Apps, we can easily format the input values for the login user format.

Go to Source and hit them a thumps up

The post Format input values using Formatting API in PCF Control within Dynamics 365 CRM appeared first on Microsoft Dynamics 365 Blog.

]]>
4351