Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Bi50zwoe80Bw5pmvQfQnCL
Power Pages - Customize & Extend
Answered

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

Like (1) ShareShare
ReportReport
Posted on 10 Sep 2024 21:23:29 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:
  • Verified answer
    BluFin.S Profile Picture
    56 on 22 Oct 2024 at 18:28:22
    Help to format a field on Dynamics 365 Sales now that Input Mask is retired
    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();
        }
    }
     
  • BluFin.S Profile Picture
    56 on 22 Oct 2024 at 17:36:05
    Help to format a field on Dynamics 365 Sales now that Input Mask is retired
    @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")
          );
       }
    }
  • Suggested answer
    SaiRT14 Profile Picture
    1,966 Super User 2025 Season 1 on 22 Oct 2024 at 00:38:09
    Help to format a field on Dynamics 365 Sales now that Input Mask is retired
    • 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 21 Oct 2024 at 16:29:55
    Help to format a field on Dynamics 365 Sales now that Input Mask is retired
     
    No, its' not calculated, i just wanna to be formatted like that when the 6 numbers are entered
  • BluFin.S Profile Picture
    56 on 12 Sep 2024 at 23:52:10
    Help to format a field on Dynamics 365 Sales now that Input Mask is retired
    @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
  • Suggested answer
    Michael E. Gernaey Profile Picture
    41,952 Super User 2025 Season 1 on 10 Sep 2024 at 23:42:07
    Help to format a field on Dynamics 365 Sales now that Input Mask is retired
    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.
     
     
     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Pages - Customize & Extend

#1
oliver.rodrigues Profile Picture

oliver.rodrigues 2 Most Valuable Professional

#1
Fubar Profile Picture

Fubar 2 Super User 2025 Season 1

#1
Ajlan Profile Picture

Ajlan 2

Overall leaderboard

Featured topics