15.08.2013, 01:16 | #1 |
Участник
|
emeadaxsupport: Mask characters
Источник: http://blogs.msdn.com/b/axsupport/ar...8/14/mask.aspx
============== Yesterday, I had a support request where customer wanted to set a fixed length for the main accounts and they did not want to specify a type of characters – they wanted to have a possibility to enter both numeric and alphabetic characters. In the form Chart of accounts, you can specify your accounts format in the field Main account mask. There you can use the following mask characters: & - allow any alphabetic character # - allows any numeric character The problem was that there’s no literal mask character that allows alphanumeric or any characters. For that purpose, we modified the table FinancialTagCategory method doesValueMatchMask adding the new mask character: ? - allow any symbol Here’re the modifications: X++: public static boolean doesValueMatchMask(DimensionValue _value, DimensionValueMask _mask) { #DEFINE.SymbolNumerals('#') #DEFINE.SymbolLetters('&') #DEFINE.AnySymbol('?') #DEFINE.FirstNumeral('0') #DEFINE.LastNumeral('9') #DEFINE.FirstLetter('A') #DEFINE.LastLetter('Z') int strLength; int i; char maskChar; char valueChar; // No mask allows any value if (!_mask) { return true; } // Value must be same length as the mask strLength = strlen(_value); if (strLength != strlen(_mask)) { return false; } // Ensure each character matches the literal mask character or is appropriate for the wildcard (number/letter) specified for (i = 1; i #LastNumeral)) { return false; } break; case #SymbolLetters: if ((valueChar < #FirstLetter) || (valueChar > #LastLetter)) { return false; } break; case #AnySymbol: break; default: if (valueChar != maskChar) { return false; } break; } } return true; } This allowed us to enter any values and still control the length of the accounts. I hope it helps some of you and highlights the general literal mask characters that, by the way, used across the product – for example, in the project module – the Subproject ID format field. Have a good day, Roman Источник: http://blogs.msdn.com/b/axsupport/ar...8/14/mask.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
15.08.2013, 08:32 | #2 |
Участник
|
прикольно.
интересно, почему не воспользовались встроенной функцией match, а занимались разбором строки вручную. |
|
|
|