Here's the code:
function formatInputNumber(executionContext) {
var formContext = executionContext.getFormContext();
var numberField = formContext.getAttribute("sic").getValue();
if (numberField && !/^\d{2}\.\d{2}\.\d{2}$/.test(numberField)) {
// Format the number (you can customize this to your needs)
formContext.getAttribute("sic").setValue(
numberField.replace(/(\d{2})(\d{2})(\d{2})/, "$1.$2.$3")
);
}
}
Use Regular Expression for Input Formatting: Since the Input Mask custom control has been retired, you can use Regular Expressions (RegEx) to enforce input formatting, like "00.00.00," using JavaScript on the form.
Create a Custom Field for the Lead Entity: Go to Power Apps > Solutions > Select your Dynamics 365 Sales Solution. Add a new text field to the Lead entity to hold the formatted number.
Add JavaScript to Enforce the Format:
function formatInputNumber(executionContext) {
var formContext = executionContext.getFormContext();
var numberField = formContext.getAttribute("new_numberfield").getValue();
if (numberField && !/^\d{2}\.\d{2}\.\d{2}$/.test(numberField)) {
// Format the number (you can customize this to your needs)
formContext.getAttribute("new_numberfield").setValue(
numberField.replace(/(\d{2})(\d{2})(\d{2})/, "$1.$2.$3")
);
}
}
formatInputNumber
) to trigger on the "OnChange" event of the new field.
oliver.rodrigues
2
Most Valuable Professional
Fubar
2
Super User 2025 Season 1
Ajlan
2