Are Epicor functions really this painful?

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.

1 Like

You can test the function in staging just pass the /staging flag on your test.

https://TLD/SDK41/api/v2/efx/staging/C001/CostFunctions/GeneratePOEstRevenue

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

5 Likes

Also, can’t even see the function details without demoting?
Also, can’t copy a function to a different library?

2 Likes

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.

1 Like

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.

2 Likes

1 Like

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.

Then in your layer you can use a BAQ to read that value into your Function Call. (But I agree it isn’t idea)

3 Likes

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.

1 Like

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 may be stretching here but you should be able to pull the API key from TransView
image

And populate that via BAQ Lookup.

I’m trying to find an example. But maybe I’m crazy… stand by while I poke about.

2 Likes

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.

:face_with_raised_eyebrow:

5 Likes

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.

What is this staging thing you guys are talking about? All I see is promote/demote?

When you demote a function, there is an endpoint available via REST with staging in the URI. I’ve never tried demoted functions in BPMs though.

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.

1 Like

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.

I have just tested this in 2021.2.6 and it is the same new behavior

Really? Why?

1 Like

Session header is sent automatically by homepage

1 Like