So I got my functions working, finally, but I just can’t believe its really this painful, surely I am missing some tricks that would make this process easier?
First, its impossible to test my function without closing out of the designer AND promoting to production? Really?? I thought writing a BPM was painful (closing out of the designer and saving before testing). But this is so much worse. I have to demote the entire library to make a small change, which breaks every other function in my library if they happen to be in use.
Then moving my library to production. I couldn’t figure out why I was getting error 401. I didn’t realize I had to make a whole new API key in the production environment, and then manually find every single instance of my functions in the layer, and manually update the key in those events. Really?? This is so nuts I can’t believe this is correct.
I really like the concept of having a reusable piece of code vs rewriting the same logic in multiple places, but this is just so painful I am really questioning whether I should use them at all.
Where are you hard coding your API key? In your application?
You should do your work / changes in your development environment and then push / move / publish that to production. So it shouldn’t break anything in production except for the split second of you installing the latest version. Don’t correct functions in live
Yes, is there another way to do it?
For example, I have an event that is calling a function in sales order entry. Its requiring me to enter my API key in the configuration of that component.
Well that’s what I was doing. But then I have to change all the keys every time I import the layer because there doesn’t see to be a way to move the key over.
Obviously had I known this was going to be an issue, I could have created the key in production, copied production to dev, and then commenced development.
But now that I have all this work in progress in dev that isn’t an option for the time being.
If you planned ahead, you can save your API key in one place in your program, and use the variable and not have to change it in a million places. Or better yet a settings file.
This isn’t something unique to Epicor. Lots of places have things like this.
edit: never mind, I thought you were talking about an external application, not with customization.
Yes this is a pain, one thing you could do which we’ve done. Which we do is have an “environment” default internal API Key that we store in Company configuration.
Ok I thought I was missing something. Yes lots of programs DO have things like this and they are manageable. From what I can tell, Epicor is forcing me to hardcode this, making it unmanageable. Unless I am missing something.
Can you describe that a little more? From what I can tell, the API key field will only accept. . . an api key. How would I “read” the key from somewhere else into it?
I know you don’t have any votes for it, but idea 2555 is to implement secret management. As Jose said, storing a single API key for all calls is not ideal. The idea has six votes - and half of those are mine. But security isn’t always popular, until it is.
Have to agree with you @aosemwengie1. Functions and libraries are great but the implementation needs some tweaking. Live and staging should be able to be live at the same time. We should be able to disable live and promote stage to live in real time, just like a BPM.
Of course, dev work should be done in dev and imported to production through the staging step.
oh ok, I’m calling the function from the layer. I need to get postman set up properly, I tried to in the process of troubleshooting this but I am doing something wrong because it just tells me invalid credentials.
For testing the function, I often use Schedule Function, as this can be used on promoted and unpromoted libraries.
In terms of the API key in Kinetic Layers. Do note that in recent versions the API Key is not required to call a function in a Kinetic layer. Application Studio still shows it as a required field; however, it can be left blank and will still work. This is definitely the case for 2022.1. Not sure about 2021.2 I’m afraid. It is still required when calling outside the application.