Show what you got. All of it.
var file = ("C:\\Users\\jbailie\\Documents\\FEDEX LTL 1.22-1.30.csv");
string row = "";
DataSet thisDS = new DataSet();
thisDS.Tables.Add("CSVRows");
DataTable dt = thisDS.Tables["CSVRows"];
try
{
this.PublishInfoMessage("Good morning!", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
/*CallService<Ice.Contracts.ServerPathSvcContract>(serverPathSvc =>
{
List<Ice.Lib.ServerPath.Types.PathInfo> pathInfo = new List<Ice.Lib.ServerPath.Types.PathInfo>();
pathInfo = serverPathSvc.GetPaths(Epicor.ServiceModel.Utilities.SpecialFolder.CompanyData, "", false);
this.PublishInfoMessage(pathInfo.ToString(), Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
if(pathInfo.Count > 0)
{
string path = file;
//File.WriteAllText(path, "In this file I put some text. You will have to do what's next.");
}
});
*/
using (System.IO.StreamReader reader = new System.IO.StreamReader(file))
{
this.PublishInfoMessage("Good afternoon!", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
string line;
while ((line = reader.ReadLine()) != null)
{
// Split the line into fields (assuming comma-separated)
string[] fields = line.Split(',');
var dr = dt.NewRow();
dr.Table.Columns.Add(fields[0]);
dr.Table.Columns.Add(fields[1]);
dr.Table.Columns.Add(fields[2]);
dr.Table.Columns.Add(fields[3]);
dr.Table.Columns.Add(fields[4]);
dr.Table.Columns.Add(fields[6]);
dr.Table.Columns.Add(fields[8]);
dr.Table.Columns.Add(fields[13]);
dr.Table.Columns.Add(fields[5]);
dt.Rows.Add(dr);
OutDS = thisDS;
dynamic exo = new System.Dynamic.ExpandoObject();
foreach (string column in dr.Table.Columns)
{
((IDictionary<String, Object>)exo).Add(column, column + "_data");
}
this.PublishInfoMessage("Good night!", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
/****************** Add to grid ******************************/
//filedata.DataSource = Newtonsoft.Json.JsonConvert.SerializeObject(exo);
}
}
}
catch (Exception ex)
{
}
thisDS.Dispose();
I donât know how to pass in a file path from a file picker widget so I have a hard coded path name for the time being. One I get it parsing and such like I want, I will address that issue.
The problem with PublishInfoMessage is if the code critically fails, youâll never see it.
Try including a string out parameter such as InfoMsg and write to that. I also like to include a string ErrorMsg and, within your catch, write your exception there.
It would be ideal to see what the actual error is vs going off, what I suspect to be, is that red herring warning message.
And the problem is that the code does critically fail. I am not seeing the message after trying to create a streamreader. That is the real issue. I will worry about messages later. This is working for me right now. I wonât have messages once I get the file to read and such. What I really want to do is choose a file, click a button and the kinetic function read the csv file I have chosen and put it back on a data grid. In classic Epicor that was easy with custom C# code but this is being a real pain. I have the button running this function code but it isnât reading the file so I can pass it back to grid. I donât even know if I have that set up correctly since I am not getting to that point.
Great. Weâre trying to figure out why. Youâre putting those messages in there to, presumably, use for debugging. As in âthis message fired, so I got to here.â
As I stated, and as you just confirmed, they donât run if your code critically fails. You need to understand why itâs critically failing. You need to put an out parameter in your catch block to actually catch the critical failure and see why itâs failing.
Youâre guessing right now. If that message confirms your suspicion, great, we can go from there, but no one wants to spend time helping you debug something if youâre not willing to go through the steps we ask.
Where are you running this code from? How are you triggering the function?
you are right. I need to out a message in the catch. I did and am now troubleshooting it.
I tried to follow the instructions listed out at the top of this thread. Great instructions btw.
I made progress. Once I put a message in the catch I found my issue. I followed the instructions above and when I try to save/compile my function I am getting an error stating that there is no argument that corresponds to the required parameter FileName. I tried to follow the instructions but am stuck on this at the moment.
Yes. If I delete it, this error will go away but I have to have it in order to get my file to come across. I can send you a screen shot but it looks exactly like this.
Are you calling that function from another function and forgetting to pass the FileName param?
No. I am doing it from, app studio.
You canât compile a function in App Studio, so thereâs a disconnect here.
If youâre receiving that parameter error in Function Entry (only exists in Classic), that tells me youâre trying to call this function from a different function and forgetting to include the parameter in the signature.
If youâre receiving that error in App Studio, that tells me you didnât define the parameter value in Method Parameters of the function widget OR you did and itâs undefined. If itâs undefined, youâll need to use Dev Tools to look at the data youâre passing and go from there.
I am made a lot of progress I think. I am to the point where I need to know where to store my excel file I am going to import. The file is coming across into my function now but my function canât see it since its on a local drive. How to I determine my server path? Also once I get it, can I copy this excel file that I am importing into the server directory somewhere?
Iâve got another example of this process coming out later today or tomorrow if you can hold on.
Hey Guys, I followed Hannahâs article and finally got the csv file data on my grid. I followed the instructions and created a new grid and such. What I need though is this data to go to an existing grid on the AP invoice Entry screen. How can I route my csv file data to that grid? Change the EPI Binding somewhere?
Change the View Name in the function widgetâs response params.
Cool. I will try that.