Dashboard add button

About Kinetic ERP in the cloud.
I need your help to make a script that takes the grid from a dashboard and transfers to a CSV file.

I have seen few examples, I am stopped because those examples mention an “oTrans” reference but when compiling the script it says that this reference does not exist.

I hope you can help me. Thank you

Hi

Please see thread: Export dasboard data to csv - Epicor ERP 10 - Epicor User Help Forum (epiusers.help)

Can you not use the Copy to Excel context menu item? then just save as CSV once the file opens? or are you trying to provide some type of automation?

Hi Aaron, in that example you mentioned, the problem I have is that the “oTrans” object tells me that it does not exist in the layer, do you know which one to invoke?

Hi Clint, I need to create a CSV file with a specific header, will it be possible to access the dashboard grid to write each line to the file? Regards.

Normally, a simple right click to invoke the Epicor context menu in a DataGrid will provide you with a Copy To Excel option which will create an Excel file using the data in the grid that you can then save to a different format (CSV).

Hi Clint, thank you for your help.
The dashboard look


And we would like to create a CSV file like this:

With the firsth lines with specific data…

You need to initiate a epiDataView with your dashboard dataview which carrys the information. There is helpers built into the customisation screen.

Youre receiving the error as youve not done this yet.

1 Like

Based on that, my understanding is that you wish to automate the process of copying the DawaView to Excel with additional headings prepended to the DataView.

Simple break down you will need a modified version of that chunk of code in thread @aarong posted and to prepend the data to write with your customized header data. Something like (based on post above) this:

private void ButtonName_Click(object sender, System.EventArgs args)
{
	// ** Place Event Handling Code Here **
	EpiDataView edvOfMyDashboard  = (EpiDataView)(oTrans.EpiDataViews["YOUR_DASHBOARD_VIEW_YOU_ATTACHED_TO"]);

	string PathToSaveTo="";
	string FileName="";
	using (System.IO.StreamWriter sw = new      System.IO.StreamWriter($@"{PathToSaveTo}\{FileName}.CSV", false, System.Text.Encoding.UTF32))

	{
		char ctab = '\t';
		string stab = "\t";
		string newline = "\n";
		string[] headerList = {"Parte", "Description", "Group producto", ... }; 
		string header = "";
		string detail = "";
		string[] preheader = {"Company", CompanyValue, newline, "Register", registerValue, newline,...}; 
		header = string.Join(stab, preheader) + newline + string.Join(stab, headerList);
		sw.Write(header + newline);

		foreach (DataRow dr in edvOfMyDashboard.dataView.Table.Rows) {
			foreach (var ay in dr.ItemArray) {
			sw.Write(ay.ToString() + "" + ctab);
			}
		}		
	}
}

Aaron, thanks a lot for your support.

Clint, thanks a lot for your support.

Welcome did anything help at all?