Search code examples
dialogaxaptax++dynamics-ax-2012uppercase

How to compare the DialogField value between a string with a difference uppercase?


I have this little question,

how I can compare the dialogField.Value() with my String, I need to have a difference between uppercase .

I used this code, but I haven't strictness, I have the true return in both case , upper and lower case.

dialogField = dialog.addFieldValue(extendedTypeStr(String30), text);
if (dialogField.value() == "TEXTCONFIRM")
{
 //other code
}

Thanks for your help,

enjoy!


Solution

  • To make a case sensitive string comparison in AX, use the strCmp function:

    if (strCmp(dialogField.value(), "TEXTCONFIRM") == 0)
    {
        // other code
    }
    

    See X++, C# Comparison: String Case and Delimiters [AX 2012] and strCmp Function [AX 2012]