REST with a 2D array (or more)

I’ve been asked to make a BAQ for REST to “simulate a sales order.” The idea is to pass in a table of values, basically - part, quantity - and return the theoretical order lines with discount, tax, etc. They want it all in one whack, apparently.

How do you do that, to have matched pairs go into a BAQ? This post is about a uBAQ, and the answer was, you can’t. (Though I just need an ordinary BAQ for now.)

If not, I dunno. Maybe populate a UD table with a REST call and then BAQ off of that? Can that even be done, using the business objects with an array?

Why do you need to use BAQ? Why not simply use UpdateExt in REST directly?
As far as I know the JSON can have multiple rows.

1 Like

This is what Epicor Functions can do for you. You need to be on 10.2.500+ though. You create your own REST API within a library and hide the implementation from the API - much like a UBAQ. You have access to the NewtonSoft JSON library so you can pull apart that JSON and then run the necessary BOs.

3 Likes

We use the standard rest api for this with the update (or update ext) method

Well, I don’t want to actually create or update a sales order. So forgive my ignorance, but wouldn’t that commit the update, or is there a pseudo-update?

@Aaron_Moreng Can you give an example of the syntax of an array? Or do you use multiple calls?

@Mark_Wonsil That was wayyyy too smart for me… I might need to digest the other answers first. We are on 10.2.500, though. I opened that functions screen once…

Got it, I thought “simulate” meant to create the order in rest or ubaq instead of the regular client.

I know that an updatable BAQ can have its own custom BPM processing and you can write c# code in there among other things.

I’m not sure about passing the parameters or calling the baq in rest though. I would describe what you are trying to do with more specific details so others might be able to help.

Use Epicor Functions like Mark said. You can’t easily do this with a BAQ. But with a function you should be able to.

1 Like

It’s for an e-commerce site - a third party, not Magneto(?). They want to send the cart (list of parts and quantities) in one call to Epicor and get a subtotal without needing to actually place the order.

So, some kind of C# code that iterates through a text list? Hmm. So it could be in any format at that point, I guess. And then return…whatever you want, really.

:exploding_head:

It could / would just be a JSON string that has whatever shape you want. Then you parse it using NewtonSoft and have at it.

2 Likes

Ahh…that’s the magic code. Not that I get all the rest, but I see after searching “NewtonSoft” on this site (and Google) that that’s the whole purpose of that.

Thank you @Mark_Wonsil as well. And everyone.

Yeesh, you people are smart.

If you can do BPMs, you can do Epicor Functions. The interface is very familiar. There’s a little more to setting up a library with references, services, etc. but seriously - it’s not more than what you already know.

I appreciate the vote of confidence. We’ll see…

1 Like

Dumb question, but is the pricing programme very complicated? We faced a similar issue but in the end I think we just replicated our pricing algorithms in php so that our website could simulate the subtotal. Then dumped the order, if it became an order, into Epicor via service connect. We update 1000s of prices each quarter, and as far as I know it’s just a CSV upload into DMT for Epicor and MySQL for the site.

No, it sure isn’t. Base price list and flat discounts based on customers. But this query is what our partner is asking for. I don’t really get why they need that, either - I sure have asked. They have a cart. Maybe it’s the taxes, since that runs through the ERP (whereas the website can handle qty x price).

And even if it was complicated pricing, they get all that on the individual parts on every REST call. But for some reason, it’s their SOP that they do like a final check or something. I think it’s mostly because they are used to integrating with that other big ERP company…

There is nobody else.

#EpicorLife