# Are Epicor functions really this painful?

**URL:** <https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721>\
**Category:** Kinetic ERP\
**Created:** [September 26, 2022, 8:57pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721 "2022-09-26T20:57:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![aosemwengie1](https://www.epiusers.help/user_avatar/www.epiusers.help/aosemwengie1/32/95533_2.png) [@aosemwengie1](https://www.epiusers.help/u/aosemwengie1)\
**Post date:** [September 26, 2022, 8:57pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/1 "2022-09-26T20:57:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [September 26, 2022, 9:02pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/2 "2022-09-26T21:02:03Z")

</div>

> [@aosemwengie1](#):
>
> First, its impossible to test my function without closing out of the designer AND promoting to production?

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

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

```

> [@aosemwengie1](#):
>
> and then manually find every single instance of my functions in the layer

Where are you hard coding your API key? In your application?

> [@aosemwengie1](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![aosemwengie1](https://www.epiusers.help/user_avatar/www.epiusers.help/aosemwengie1/32/95533_2.png) [@aosemwengie1](https://www.epiusers.help/u/aosemwengie1)\
**Post date:** [September 26, 2022, 9:02pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/3 "2022-09-26T21:02:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aosemwengie1](https://www.epiusers.help/user_avatar/www.epiusers.help/aosemwengie1/32/95533_2.png) [@aosemwengie1](https://www.epiusers.help/u/aosemwengie1)\
**Post date:** [September 26, 2022, 9:03pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/4 "2022-09-26T21:03:16Z")

</div>

> [@josecgomez](#):
>
> Where are you hard coding your API key? In your application?

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.

---

<div class="post-metadata">

**Author:** ![aosemwengie1](https://www.epiusers.help/user_avatar/www.epiusers.help/aosemwengie1/32/95533_2.png) [@aosemwengie1](https://www.epiusers.help/u/aosemwengie1)\
**Post date:** [September 26, 2022, 9:04pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/5 "2022-09-26T21:04:48Z")

</div>

> [@josecgomez](#):
>
> 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

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.

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [September 26, 2022, 9:06pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/6 "2022-09-26T21:06:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aosemwengie1](https://www.epiusers.help/user_avatar/www.epiusers.help/aosemwengie1/32/95533_2.png) [@aosemwengie1](https://www.epiusers.help/u/aosemwengie1)\
**Post date:** [September 26, 2022, 9:08pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/7 "2022-09-26T21:08:04Z")

</div>

> [@Banderson](#):
>
> you can save your API key in one place in your program

 ![image](https://www.epiusers.help/uploads/default/original/3X/b/0/b00322f48a36446020f8dfc38655a9a172b45779.png)

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [September 26, 2022, 9:08pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/8 "2022-09-26T21:08:15Z")

</div>

> [@aosemwengie1](#):
>
> I could have created the key in production, copied production to dev, and then commenced development.

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.

 ![image](https://www.epiusers.help/uploads/default/original/3X/5/5/55ece3916e1dcbf6b3d870e7db6600fbb0acbbe7.png)

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

---

<div class="post-metadata">

**Author:** ![aosemwengie1](https://www.epiusers.help/user_avatar/www.epiusers.help/aosemwengie1/32/95533_2.png) [@aosemwengie1](https://www.epiusers.help/u/aosemwengie1)\
**Post date:** [September 26, 2022, 9:08pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/9 "2022-09-26T21:08:46Z")

</div>

> [@Banderson](#):
>
> _edit_: never mind, I thought you were talking about an external application, not with customization.

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.

---

<div class="post-metadata">

**Author:** ![aosemwengie1](https://www.epiusers.help/user_avatar/www.epiusers.help/aosemwengie1/32/95533_2.png) [@aosemwengie1](https://www.epiusers.help/u/aosemwengie1)\
**Post date:** [September 26, 2022, 9:09pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/10 "2022-09-26T21:09:50Z")

</div>

> [@josecgomez](#):
>
> read that value into your Function Call.

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?

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [September 26, 2022, 9:20pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/11 "2022-09-26T21:20:18Z")

</div>

I may be stretching here but you should be able to pull the API key from TransView  
 ![image](https://www.epiusers.help/uploads/default/original/3X/a/7/a7d456cbcfc81e34a1817c6a317151d4d8c02c25.png)

And populate that via BAQ Lookup.

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

---

<div class="post-metadata">

**Author:** ![Mark\_Wonsil](https://www.epiusers.help/user_avatar/www.epiusers.help/mark_wonsil/32/51594_2.png) [@Mark\_Wonsil](https://www.epiusers.help/u/Mark_Wonsil)\
**Post date:** [September 26, 2022, 9:45pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/12 "2022-09-26T21:45:33Z")

</div>

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.

🤨

---

<div class="post-metadata">

**Author:** ![Mark\_Wonsil](https://www.epiusers.help/user_avatar/www.epiusers.help/mark_wonsil/32/51594_2.png) [@Mark\_Wonsil](https://www.epiusers.help/u/Mark_Wonsil)\
**Post date:** [September 26, 2022, 9:53pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/13 "2022-09-26T21:53:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aosemwengie1](https://www.epiusers.help/user_avatar/www.epiusers.help/aosemwengie1/32/95533_2.png) [@aosemwengie1](https://www.epiusers.help/u/aosemwengie1)\
**Post date:** [September 26, 2022, 9:54pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/14 "2022-09-26T21:54:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mark\_Wonsil](https://www.epiusers.help/user_avatar/www.epiusers.help/mark_wonsil/32/51594_2.png) [@Mark\_Wonsil](https://www.epiusers.help/u/Mark_Wonsil)\
**Post date:** [September 26, 2022, 10:00pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/15 "2022-09-26T22:00:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aosemwengie1](https://www.epiusers.help/user_avatar/www.epiusers.help/aosemwengie1/32/95533_2.png) [@aosemwengie1](https://www.epiusers.help/u/aosemwengie1)\
**Post date:** [September 26, 2022, 10:02pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/16 "2022-09-26T22:02:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BenWheeldon](https://www.epiusers.help/letter_avatar_proxy/v4/letter/b/eada6e/32.png) [@BenWheeldon](https://www.epiusers.help/u/BenWheeldon)\
**Post date:** [September 29, 2022, 10:23am UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/17 "2022-09-29T10:23:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BenWheeldon](https://www.epiusers.help/letter_avatar_proxy/v4/letter/b/eada6e/32.png) [@BenWheeldon](https://www.epiusers.help/u/BenWheeldon)\
**Post date:** [September 29, 2022, 10:48am UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/18 "2022-09-29T10:48:12Z")

</div>

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

 ![FunctionFromKineticLayerWithoutAPIKey](https://www.epiusers.help/uploads/default/original/3X/7/2/720154261c0d1c752ca03e24f060361a8856f600.png)

---

<div class="post-metadata">

**Author:** ![aosemwengie1](https://www.epiusers.help/user_avatar/www.epiusers.help/aosemwengie1/32/95533_2.png) [@aosemwengie1](https://www.epiusers.help/u/aosemwengie1)\
**Post date:** [September 29, 2022, 11:59am UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/19 "2022-09-29T11:59:19Z")

</div>

> [@BenWheeldon](#):
>
> in recent versions the API Key is not required to call a function in a Kinetic layer

Really? Why?

---

<div class="post-metadata">

**Author:** ![Olga](https://www.epiusers.help/letter_avatar_proxy/v4/letter/o/57b2e6/32.png) [@Olga](https://www.epiusers.help/u/Olga)\
**Post date:** [September 29, 2022, 2:14pm UTC](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721/20 "2022-09-29T14:14:08Z")

</div>

> [@Insert API key into Kinetic customization](https://www.epiusers.help/t/insert-api-key-into-kinetic-customization/91122/20):
>
> Actually, Brian reminded me that if you have Session in the home page (and you should have), then Api Key is not required. You need to send Session header and it is sent automatically in Homepage. You should try.

Session header is sent automatically by homepage

[Next page](https://www.epiusers.help/t/are-epicor-functions-really-this-painful/94721.md?page=2)
