Saturday, November 11, 2017

Dynamics 365: MACRO OR CONST?

Macros still are supported on Dynamics 365 but now with the VS we can and should use “const” (Constants).
#define.MyMacro("Pankaj");
const str MyConstValue = "Pankaj-Constant";
info(strFmt("%1 - %2",#MyMacro, MyConstValue ));

If you want to use “const” in the same way that we were using before with a Macro file then you should replace the for a “static class”. See the example below:
static class MyConstClass()
{
   static const public str MyConstValue = "Pankaj-Constant";
}

Using the constant class:
str a = MyConstClass::MyConstValue;

It is advisable to use “const” instead of “macro”, and they are number of benefits:
  • ·         IntelliSense in the editor.
  • ·         Support for “Go to definition” in the editor.
  • ·         Full control of the type for the constant.
  • ·         Faster compilation – macros are notorious hard for the compiler to handle.
  • ·         None of the macro idiosyncrasies – like the ability to redefine/override.
Happy DAXing....😊

Enable UAT database over OneBox DevTest environment using JIT

 Dear Friends, In this Article I will show you how to enable UAT database access for Development machine using just-in-time (JIT). Many time...