Kinetic, Application Studio, Server Files (Saas)

Stuck again…Background:

Had classic UI customization, press button, populate a draft email (.eml file) based on data relating to an order, allow user to edit the draft email, and then send it.

Was able to move it to a function, Kinetic web calls the function, then thru the Javascript hack was able to send the data back to the client and display the draft for editing and sending.

Alas, the Javascript approach has been disabled by Epicor because it’s a security concern, so now I need another approach.

I see in the Application Studio Toolbox there is a component called “file-transfer-erp” that indicates it can take a file from a server folder and send it to the client’s browser’s download folder, that would probably work for my purposes.

Couldn’t find any documentation on how to use it, has anyone else tried ?

My function returns a blob of data that wants to become the server file, but it’s not clear to me how to get the file written to the server location.

There is this post:

and this one, talks about Ice ServerPath service, but is intended for use in a BPM

I’ve been trying to get it to work in my function, but I don’t seem to be able to add the correct references to use the service

Looking for any ideas

Thanks, Scott

Check this out and see if it helps: How To: Kinetic - Upload a Client File, Parse, and Display in a Grid - Experts’ Corner - Epicor User Help Forum (

1 Like

Oh, there’s some great nuggets in there, Thanks, I’ll be digging thru it

1 Like

btw, your function code will help, although my plan is to create a file on the server and then use the file-transfer-erp widget to download instead of upload.

I notice you “hardcoded” the path, one of the posts I linked to mentioned it may not be a good practice in case they change them in future upgrades, and to use the ServerPath service instead.

But I suppose maybe it’s not as much of a risk for you since your not Saas, plus I’m not sure about getting the reference of that service into my function, no luck so far, so I’ll probably be hardcoding the path at least for now anyway

1 Like

I mean, I can’t imagine it’s much different. It’s a good starting place if nothing else.
I haven’t had a chance to play with the download.

It was mostly for example, but you’re right, it’s not good practice. Stuff changes, things break… that’s Jose’s problem? Rofl

I’d poke it with a stick again, but to be honest, I don’t wanna do jack today :slight_smile:

The struggle is real. :weary:

I poked it with a stick. It works.

I shoved a value in TransView.MyFile for a file I knew was in that folder.

I set up a button with this on-click event.

When I clicked it, my file downloaded. No muss, no fuss.

1 Like

Confused, how did the file name get (“shoved”) into TranView.MyFile ?

That would solve half my problem, the other half is how do I create a file on the server ?
My Function returns a data buffer that I want to turn into a file to download.

I don’t think I can use a similar approach that @hmwillett did as I am Saas,
I can’t just reference the server in the cloud from my function, I need another mechanism I think

(Saw your presentation at insights, nice job !)

1 Like

When I get back to the computer I can probably put together a few pointers.

I have no idea what’s accessible in the cloud, but you should be able to write to the server somehow? I mean, plenty of things export from Epicor onto the server location such as process logs and whatnot.

Would something like Session.AppServerURL + @"\EpicorData" work?

In a function:

//ref: Ice.Contracts.Lib.ServerPath
//using System.IO;

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);
    if(pathInfo.Count > 0)
        string path = $"{pathInfo.First().FullName}\\testing.txt";
        File.WriteAllText(path, "In this file I put some text. You will have to do what's next.");  

Inspiration originally from The Great @Mark_Wonsil

You all inspire me @hmwillett, @klincecum, @Mark_Wonsil, @josecgomez (and others)

It’s funny I put that link (Mark’s post) at the start of my post, but when I first tried the GetPaths thing, I could not find that darn reference for some reason.

Regardless, I got the two pieces working (file write in function, event handler downloads file with file-transfer-erp component, just need to wire it together and make it all official like

Thanks for the assistance !

btw, fwiw, I wanted to put my file in a folder per user, so I used type “SpecialFolder.UserData” and tried to create a folder with C# Directory.CreateDirectory(), but it didn’t seem to like that…

then I tried specifying the folder name as the 2nd parameter to GetPaths() and when the folder doesn’t exist it creates it and my file gets created there.

That’s exactly how it works. I was investigating with the REST interface and saw all these new folders popping up and I’m thinking, “WT…” Of course I was using POST so that makes sense.

Epicor already has a folder structure for single users though, so I might piggy-back off of that by first looking up the user and have the service build the user folder if missing. I believe you could put application specific folders under that user folder if needed.

1 Like