I am writing a function on my new layer that requires an Open File Dialog? May I do it in my C# function code? If so, what is it I need to include in my references? If not, is there a function I can add to my button click in Application Studio?
The function code runs on the server, so prompting for file upload is not allowed.
There is a file transfer widget you can use in your button-click event to get and store the file, then pass its location to a function to be processed on the server.
I think this will help a lot. Thank you. I will let you know how it goes.
It works a treat. There are a few examples on here somewhere.
I found this to help solve my issue.
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.Count.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.");
}
});
but am unsure what to do now. I want to read the CSV records into a data structure (List?) and then attach that to a grid’s data source. Do you guys have any pointers or ideas that can get me pointed in the right direction?
That link above in this very thread has all the steps and working code . . .
Actually it doesn’t work. I am trying to write a Kinetic function and the FileStream specific stuff does not exist in current context. I tried using System.IO and that doesn’t work either with my version.
You can use the new sandbox method and it works the same way.
var filePath = new FilePath(ServerFolder.CompanyData, @"MySubfolder\" + this.FileName);
using (var streamReader = this.Sandbox.IO.File.OpenText(filePath))