Format input values using Formatting API in PCF Control within Dynamics 365 CRM

By | March 6, 2021

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


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