giovedì 7 ottobre 2021

D365FO - New cut and paste options

 Is it possible to copy data directly with a cut and paste from excel for multiple lines?

Now yes, I'll show how.

Starting from an excel having all the lines properly ordered.


We copy using CTRL-C function the lines to be copied.

Then we open the correspondent form in D3650FO, create a new line.


And finally click CTRL-V.

It applies also to multiple rows, and in case of errors it is requested a correction by the user in interactive mode.

mercoledì 6 ottobre 2021

D365FFO - Richiamare metodi privati all'esterno della classe

Questo link mostra come usare la  reflection del C# per richiamare metodi privati statici o di istanza di una determinata classe in AX.

https://axvigneshvaran.wordpress.com/2018/01/05/how-to-access-call-private-protected-methods-variables-in-a-class-table-using-reflection/

Supponiamo di avere una classe fatta così:

 class MyClass  
 {  
      private static int sumPrivate(int a, int b)  
      {  
           return a+b;  
      }  
   
      private int sumInstancePrivate(int a, int b)  
      {  
           return a+b;  
      }  
 }  
possiamo accedere ai due metodi privati così:

 using System.Reflection;  
   
 class testReflection  
 {  
   public static void main(Args _args)  
   {  
     int      ret;  
     System.Object[] parametersArray = new System.Object[2]();  
     parametersArray.SetValue(5, 0);  
     parametersArray.SetValue(2, 1);  
       
     System.Type   myType;  
     DictClass    dt = new DictClass(classNum(MyClass));  
     Object     classInstance = dt.makeObject();  
             
     var bindFlags = BindingFlags::InvokeMethod |   
                               BindingFlags::NonPublic |   
                               BindingFlags::Static | BindingFlags::Instance;  
     
     myType = classInstance.GetType();  
   
     //richiama il metodo statico  
     ret = myType.InvokeMember(staticMethodStr(MyClass,sumPrivate),bindFlags,null,null,parametersArray);  
   
     //richiama il un metodo di instanza  
     var methodInfo = myType.GetMethod(methodStr(MyClass, sumInstancePrivate), bindFlags);  
   
     if (methodInfo)  
     {  
                // Or use “new System.Object[0]()” instead of parametersArray if you do not have any parameters  
       ret = methodInfo.Invoke(classInstance, parametersArray);   
     }  
   }  
 }  

N:B: Mina le basi della programmazione ad oggetti :)