How to work with Dashboards with Acumatica Test SDK
In this article, I will explain how to work with Dashboards using the Acumatica Test SDK framework. It is important to note that it is not possible to generate wrappers for all dashboards by default — only DB000038 has a built-in wrapper class.
Therefore, in order to access any other dashboard, it is necessary to generate a custom wrapper class.
Below is an example of code that automates the process of generating wrapper classes:
public void GenerateWrappers()
{
string projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName; //retrieves the root path of the current project by navigating three levels up from the current working directory.
string wrapperPath = String.Format(projectPath + @"C:\TestSDKOutput"); //constructs a file path where the generated wrapper classes will be stored.
ClassGenerator.ClassGenerator WG = new ClassGenerator.ClassGenerator(@"C:\Program Files\Acumatica ERP\Deel", @"C:\TestSDKOutput"); //specifies the SitePhysicalPath and GenResultPath
WG.Username = "admin"; //specifies the Username needed for authentication
WG.Namespace = "GeneratedWrappers.Acumatica"; //specifies the Namespace where wrappers will be generated
WG.Dashboards.Add("DB000040"); //adds a specific dashboard ID to the list of screens that the generator will process.
WG.Run("AP301000"); //triggers the generation of wrapper classes specifically for "AP301000".
}
Note: ClassGenerator requires .NET Framework 4.8 because it uses APIs that exist only in the .NET Framework and will not work with .NET 6 or .NET 7.
Also, it is important to ensure that ChromeDriver is running before you start generating the wrapper.
So, once the above method is executed, the following output should appear in the console window:
At this point, you can verify that the generated wrapper class has been created in the specified output folder. Now, you can add it to your project in order to access the needed Dashboard.