As you know X++ supports methods with default values. In Ax it’s possible to detect when such a default value was used at runtime with prmIsDefault(). To see this for yourself, create a class with a method like this:
void someMethod(int i = 1) { ; if (prmIsDefault(i)) { info('Default'); } else { info('Value given'); } } |
o.someMethod(); o.someMethod(1); |
Now you may be wondering how this can be useful. Some scenarios:
- Avoiding expensive operations if the default value was used
- Avoiding unwanted initializations
- Dealing with customizations that require extra parameters in standard Ax classes
Reposted from http://sysdictcoder.com/detecting-default-values/