cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

MDK 25.6 : Format Rule Not Applying Correctly

Sourabh1
Participant
0 Kudos
162

Hello Everyone,

I'm encountering an issue with my MDK Android application (built with MDK 25.6 and running on Android 14) where my formatrule is not applying as expected. The rule is designed to clean phone number inputs by removing non-digit characters and optionally limiting to 10 digits.

Here's the JavaScript code for the one of format rule PhoneNumberFormat rule:

JavaScript
 
/**
 * Describes this function...
 * @param {Icontext} context
 */
export default function PhoneNumberFormat(context) {
    // Get the current value of the control
    let value = context.getValue();

    // If input value is falsy (e.g., if the user deletes the input), then just return
    if (!value) return value;

    // Remove all non-digit characters
    value = value.replace(/\D/g, '');

    // Limit to 10 digits (optional, adjust as needed)
    if (value.length > 10) {
        value = value.substring(0, 10);
    }

    return value;
}

When testing on an Android 14 device, the input field does not seem to respect this formatting; non-numeric characters are not being removed, and the length restriction is not enforced visually or upon input.

I have already verified the following:

  • Rule Definition: The PhoneNumberFormat rule is correctly defined and present in the MDK metadata.

  • Target Control: The rule is properly assigned to the FormatRule property of the relevant SimpleProperty .

  • Data Binding: The control's Value property is correctly bound to a data source.

  • MDK Client Version: I'm using an MDK client built with MDK SDK version 25.6.

  • Android Version: The issue is observed on devices running Android 14.

Could you please provide insight into any known compatibility issues with format rules on MDK 25.6 running on Android 14, especially concerning string manipulation or input validation? Additionally, are there any specific debugging steps or workarounds you'd recommend for this scenario?

Accepted Solutions (0)

Answers (1)

Answers (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Personally I don't use format rules often but I did run a quick test and am seeing similar behavior.  You can work around this moving your rule to OnValueChange and calling context.setValue(value,false) as the return.  

I will open an internal issue to investigate further.