web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Help to format a field...
Power Pages
Answered

Help to format a field on Dynamics 365 Sales now that Input Mask is retired

(1) ShareShare
ReportReport
Posted on by 56
Hello,

Can anybody tell me what is the alternative for Input Mask custom control to use in forms of model-driven apps? As the control is retired so need to know the alternative.
I need to specifically edit the module Lead on Microsoft Dynamics 365 Sales adding a field with this formatting number "00.00.00"

I've spent 2 evening without find the solution, can u please help me step by step?

Thank you in advance

PS:
Asked also to copilot but i did not understood how use "concatenate" :)
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,493 Super User 2025 Season 2 on at
    Hi
     
    I am a dorko maybe, but I do not understand how the first 2 sentences are related.
     
    Are you saying you want to create a Calculated (Formula Column) that takes the value from one of your columns and makes it look like 00.00.00
     
    If so thats what it meant by concatenate. However I would need to see the actual DATA (at least a few rows, even if fake) of what the field has in it
    so I can tell you the formula to type in.
     
     
     
  • BluFin.S Profile Picture
    56 on at
    @flmike thank you i make you an example:

    Module Field: NACE Code
    It's made of 6 digit numbers
     
    When the sales enter it i i dont want to see: 789632 instead i want it auto-formatted with dot like: 78.96.32

    I hope its clear now
  • BluFin.S Profile Picture
    56 on at
     
    No, its' not calculated, i just wanna to be formatted like that when the 6 numbers are entered
  • Suggested answer
    SaiRT14 Profile Picture
    1,990 Super User 2025 Season 2 on at
    • 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")
          );
       }
    }
     

    • Attach JavaScript to the Lead Form: Set the JavaScript function (formatInputNumber) to trigger on the "OnChange" event of the new field.

     

  • BluFin.S Profile Picture
    56 on at
    @SaiRT14 thank you very much for your help btu something doesn't work, i have also tweaked the script with the correct field name for "Codice ATECO/NAC" that is "sic"

    Can you help me troubleshooting it?
     







    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")
          );
       }
    }
  • Verified answer
    BluFin.S Profile Picture
    56 on at
    Thanks SaiRT14  you have pointed me, the right direction, and finally i have fixed the script this way:

     
    function formatSICField(executionContext) {
        var formContext = executionContext.getFormContext();
        var sicField = formContext.getAttribute("sic").getValue();
        if (sicField && sicField.length === 6) {
            var formattedSIC = sicField.replace(/(\d{2})(\d{2})(\d{2})/, "$1.$2.$3");
            formContext.getAttribute("sic").setValue(formattedSIC);
        }
    }
    function validateSICField(executionContext) {
        var formContext = executionContext.getFormContext();
        var sicField = formContext.getAttribute("sic").getValue();
        var regex = /^\d{2}\.\d{2}\.\d{2}$/;
        if (sicField && !regex.test(sicField)) {
            formContext.getControl("sic").setNotification("Invalid format. Please use the format 00.00.00.");
        } else {
            formContext.getControl("sic").clearNotification();
        }
    }
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 89 Super User 2025 Season 2

#2
Jerry-IN Profile Picture

Jerry-IN 75

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard