jkane
(John Kane)
September 22, 2022, 7:41pm
1
I am attempting to create a Function to be used as an API. This is my very first attempt and am failing miserably. I think it is because I am lazy and don’t want to do to much work that might end up being unnecessary.
With that said, my question is do I have to trace a transaction in the system and then replicate ALL of the method calls?
hmwillett
(Hannah Willett)
September 22, 2022, 7:46pm
2
Generally, yes.
** I say generally because sometimes you can get away with not calling some. Couldn’t tell you which–you’ll have to discover that on your own. If you’re just starting out, you should just replicate them all.
Here’s an example I’m working on with Inventory Transfer. The red ones I’m skipping.
1 Like
+1 on what @hmwillett is saying.
Generally, the ones I don’t use are the calls to fill drop-down boxes or other UI-related purposes. An API won’t need those.
3 Likes
JasonMcD
(Jason McDermott)
September 22, 2022, 8:15pm
4
hmwillett:
Inventory Transfer
@jkane I might suggest don’t start with inventory transfer…
I made an EFx for that a few months ago. It’s a bear. I went totally rogue on that since the trace seems to leave out a lot of details.
Maybe start with something simpler…
But huzzah and you can do it!
2 Likes
hmwillett
(Hannah Willett)
September 22, 2022, 8:15pm
5
You’re not wrong, lol.
Freaking deferred updates…
1 Like
JasonMcD
(Jason McDermott)
September 22, 2022, 8:16pm
6
No, wait, I take that back - it was issue material .
Sorry, I did both around the same time. Inventory transfer might be fine.
1 Like
JasonMcD
(Jason McDermott)
September 22, 2022, 8:18pm
7
hmwillett:
deferred updates
Oh, yeah that.
So yes @hmwillett if you do finish this, I would like to learn from it. I think we are still getting bit from that here.
1 Like
jkane
(John Kane)
September 22, 2022, 8:28pm
8
I don’t know if Quote is simpler, but that’s what I’m starting.
jkane
(John Kane)
September 22, 2022, 8:37pm
9
Is it one big chain of Widgets or should I create a bunch of Functions in a single Library for each method?
So it would be one Function for creating the header, getting customer info, etc, and update. Then a second function for creating a line, etc.
JasonMcD
(Jason McDermott)
September 22, 2022, 8:39pm
10
Isn’t there a restriction where you can’t call a function from another function in the same library ?
1 Like
hmwillett
(Hannah Willett)
September 22, 2022, 8:40pm
11
Just create one function to do the thing. All of the code or BO widgets can be in the single function. Then call the function as needed to do the thing.
2 Likes
hmwillett
(Hannah Willett)
September 22, 2022, 8:40pm
12
Not anymore.
You can also get around that using reflection if on a version that does.
2 Likes
JasonMcD
(Jason McDermott)
September 22, 2022, 8:41pm
13
And you can copy widgets from one function to another if needed. So if you wanted to test pieces and then assemble them.
2 Likes
jkane
(John Kane)
September 22, 2022, 8:50pm
14
As always, you people are the best! I’m diving in
2 Likes
Hally
(Simon Hall)
September 23, 2022, 12:13pm
15
Start simple,
Test with Postman/ API help or similar,
Then build it up,
Save yourself some pain from having to publish/promote the function and use the staging address…Not at my PC to give you an exact example url.
There are some examples for calling the rest API in the online help, including an example web app.
3 Likes
hmwillett
(Hannah Willett)
September 23, 2022, 1:01pm
16
https://{{host}}/{{epicor_instance}}/{{FunctionAPIEndPoint}}/staging/{{Company}}/{{FunctionLibrary}}/{{Function}}
2 Likes