Help with function to run ATP for the user

I’m trying to write a function that can be called with a part number and quantity, and get the ATP date back from the ATP service. I’m not sure what I need to fix in my function to get it to return the right answer. Right now, it doesn’t fail, it just always returns an answer of today (when the answer isn’t today).

Epicor ATP screen:

vs. the function result:
image

When I look at how Epicor is calling the service, it looks like it called OnChangePlantWithDS and then OnChangeField (when entering the qty) so I tried to mimic that in the function but I’m doing something wrong.



Are you passing in your plant in callcontext client when you call the function from REST?

I see you are using it as input but if you aren’t populating it on the rest call

I’m just calling it from postman right now. I tried putting the site as an input on the function and hardcoding it to make sure but it still gives the same error.

I guess a better question is, how can I actually see the data that is being sent to the service by the function, the same way I can see when I trace the way Epicor is doing it?

If you are calling it from postman and using callcontextclient you need to pass on a CallSettingsHeader / CallContextHeader to set the plant

Alternatively if you are passing it as input (the plant) you’ll have to use a Temporary Session Creator to switch pants server side before making the BO call

2 Likes

Oh! I get what you’re saying now. Calling it through the Epicor rest help page I see its not getting the plant:

Ok its now populating the plant in the Callsettings and the ContextHeader but still giving the same (wrong) answer.

Why are you ignoring the StartDate? (Note I’m not familiar with this BO just curious if that matters )

There isn’t a place to pass it into the second call, and its an output on the first call, so I’m having a hard time understanding what to do with it. I’ve mapped it to a variable now instead of ignoring it but still not sure what to do with it?

Let’s back up, why do you need this field, and in what state is the record at when you are querying it?

The BOs you are calling are intended for building/editing the datasets, not getting data from.
(In rare cases, that may be what you need.)

If this record already exist, you probably need a getbyid/getlist/getrows.

It’s not a record, ATP is the service that is called when you run the Available to Promise screen.

  1. Go into Available to Promise
  2. Select the Part
  3. Type in the Quantity
  4. Epicor hits the ATP service and tells you the date that quantity will be available

I want to do this with a function instead of the ATP screen.

I fully agree I am misunderstanding how this works . . .just having a hard time putting the pieces together.

When I watch what Epicor is doing, I see the ATP date come back as an output on that second service call, so that is the theory I was following when I attempted to build this. But I do see some GetLists scattered in there so that is probably what I am missing. I will try to follow the trace more closely and see if that works.

You should just have to call the OnChangeField one.

How (Did you?) fill the dataset you are passing it?

I’m relying on the first call to populate the ds for the second call because it looks like that is how Epicor is doing it. Its the same dataset in and out on both calls. The first one is supposed to populate all the demand and supply records for that part. I wish I could see what is getting populated in there because that would probably make it really clear why its not working.

̶I̶t̶ ̶d̶o̶e̶s̶n̶’̶t̶.̶ ̶T̶h̶a̶t̶ ̶d̶a̶t̶a̶s̶e̶t̶ ̶i̶s̶ ̶b̶u̶i̶l̶t̶ ̶b̶e̶h̶i̶n̶d̶ ̶t̶h̶e̶ ̶s̶c̶e̶n̶e̶s̶ ̶̶i̶n̶ ̶t̶h̶i̶s̶ ̶o̶n̶e̶̶.̶ ̶S̶o̶ ̶i̶f̶ ̶y̶o̶u̶ ̶w̶a̶n̶t̶ ̶t̶o̶ ̶d̶o̶ ̶i̶t̶ ̶e̶i̶t̶h̶e̶r̶ ̶w̶a̶y̶,̶ ̶y̶o̶u̶’̶l̶l̶ ̶n̶e̶e̶d̶ ̶t̶o̶ ̶b̶u̶i̶l̶d̶ ̶t̶h̶a̶t̶ ̶d̶a̶t̶a̶s̶e̶t̶ ̶y̶o̶u̶r̶s̶e̶l̶f̶.̶

̶A̶n̶d̶ ̶s̶i̶n̶c̶e̶ ̶y̶o̶u̶ ̶w̶i̶l̶l̶ ̶h̶a̶v̶e̶ ̶t̶o̶ ̶b̶u̶i̶l̶d̶ ̶i̶t̶ ̶a̶n̶y̶w̶a̶y̶,̶ ̶y̶o̶u̶ ̶c̶a̶n̶ ̶s̶k̶i̶p̶ ̶t̶h̶e̶ ̶f̶i̶r̶s̶t̶ ̶c̶a̶l̶l̶,̶ ̶a̶n̶d̶ ̶g̶o̶ ̶s̶t̶r̶a̶i̶g̶h̶t̶ ̶t̶o̶ ̶O̶n̶C̶h̶a̶n̶g̶e̶F̶i̶e̶l̶d̶.̶

Let me test and make sure I’m looking at this right, I do that sometimes :slight_smile:

When I am watching Epicor do it, the ATP records are empty in the ds going into the first call, and come out populated, so that is why I thought I could do it the same way. Building those records would be a lot of work.

I was looking at the trace wrong. You can get a dataset back from OnChangePlant.

So if you can store it, you just need to set the fields in there.

You’ll need to set (in the ds)

  • SellingATPQty
  • OurATPQty
  • RowMod to U
1 Like

Ok, so I need a step in between the two service calls to do that?