Rest-ERP Error When Calling SalesOrderSvc

Good afternoon,

I’m using the rest-erp widget in application studio to pull information into Case Entry, RMA Processing, and Service Call Center. RMA Processing and Service Call Center are both giving me issues, while Case Entry is working as expected. My error is coming from the UD03Svc call, but there is something wrong with the information coming from the SalesOrderSvc call. Here is an overview of what I’m trying to accomplish:

Once in Line Details, I want to use RMADtl.OrderNum to pull in order information (we have some UD fields that correspond to UD03 on our OrderHed table). Then I’m trying to look up the records in UD03 based on this order information but I receive this error:

Parameter key2 is not found in the input object

I have been fiddling with this all day. It is set up identically in Case Entry, yet I run into zero issues when using that application. Below are some screenshots of my SalesOrderSvc call.
image
image

Any ideas would be greatly appreciated. I used the rest api help tool and running through the SalesOrder and UD03 services there I am seeing the results I want.

Are you sure the error is coming back from the SalesOrderSvc? There is no Key2 parameter on SalesOrder.GetByID … but there is a Key2 on UD03.GetByID which you call immediately after. Maybe the issue lies in that second rest call?

Hey Jonathan, yes, the error is occurring on the UD03Svc, but it’s occurring because there is no order information from the SalesOrderSvc. Does that make sense?

For the UD03Svc call key1 is a hardcoded value, that’s why it’s not throwing an error, key2 references that OrderHedView from the previous call.
image

Ahh gotcha - sorry for missing that in your original post.

and what you are showing looks exactly as I would expect - based on looking at what I made last week for UD13 BO

Do you see the network call to SalesOrderSvc going through? To clarify: is the response coming back empty? or is there data in the response, just not in the data view (OrderHedView)?

Test the UD03 getbyid with the BL tester (if you can)

I think it requires all key fields to be populated… even if they are empty

I think you are going to have to do some error checking in the form, or better yet, move this logic to a function so you can check properly.

1 Like

Good morning Jonathan. This is what I’m seeing. Don’t see any data returned.

Could it just be that some services can’t be called from RMA Processing? The only data I see is the OrderNum I’m passing to SalesOrderSvc.

Simon, you are correct. I’m passing through blank values for key3-5

1 Like

This is showing an error coming back from your SalesOrderSvc call:

I can’t see all of it, but something is undefined.

I’m confident that this is not the case. You can call these rest services from outside of Epicor, even.

Kevin has the right of it: functions have several potential advantages over multiple rest calls from the client
OR perhaps add the data you need to the RMADtl using a BPM (if there is only one UD03 record per RMAdtl)

2 Likes

This is the error:

Cannot read properties of undefined (reading ‘toLowerCase’)

Have no clue what it’s referring to. I will take @klincecum’s advice and give it a shot. Thanks for your all’s help and advice.

1 Like

Good morning,

Having some issues with the function I tried to build out. It’s a really simple function inputting an order number and should spit out three values from the order. My first thought is that I am not using the function correctly in Kinetic, but I’ve attempted accessing it via the API and receiving nothing in my responses, Internal Server Error (500). We are cloud based so no access to the actual server, and the function is published. Have you ever run into an internal server error when writing a function?

All the time.

Simple debug tip:

Add another output to the function. Wrap all your code in a try / catch block.

Catch the exception in the block, and shove it in the extra output with ex.ToString();

Then run it somewhere you can see the outputs.

try
{
    //Function code here
}
catch (Exception ex)
{
   myExtraOutput = ex.ToString();
}

Gotta run out of town. Need more help, post your code here, someone will see it.

2 Likes

Hi Jaren,

Sorry to dive in late on this… but quick question… have you tried passing a different Field Value to see if it goes through successfully? Whether it is a hardcoded value… or a different field?

I’m not saying this is your issue… but early on in Kinetic (VERY early on)… I had an issue with using an underscore in my UD field name. After hours of working with Epicor employees, we found that the underscore was the issue. When I made new UD Fields without the underscore, the customization worked with no issue.

Again, this was very early on in Kinetic and they may have fixed that issue. I was just curious, if you changed the Field Value to something more basic… does your Rest call go through?

David, yes I do have some fields that contain underscores. Here is the code:

var OH = (from OHR in this.Db.OrderHed
	  where OHR.Company == Session.CompanyID &&
	  OHR.OrderNum == this.OrderNum
	  select OHR).FirstOrDefault();

if (OH != null)
{
	this.EndUser2 = OH.End_User2_c;

	var EU1 = (from UDR in this.Db.UD03
		  where UDR.Key1 == "EU1" &&
		  UDR.Key2 == OH.End_User1_c
		  select UDR).FirstOrDefault();

	if (EU1 != null)
	{
		this.EndUser1 = EU1.Character01;
	}

	var FDC = (from FDCR in this.Db.Country
		  where FDCR.CountryNum == Convert.ToInt32(OH.Final_Dest_Country_c)
		  select FDCR).FirstOrDefault();

	if (FDC != null)
	{
		this.FinalDestinationCountry = FDC.Description;
	}
}

EDIT:
Okay, so changed the code and got it working. I’ll update once I get it working in Kinetic.

2 Likes

Okay, I am having trouble getting the response put into a view. I have done this with built in Epicor services and it worked fine, but basically I would create a view from OrderHed, then pass the OrderHed parameter to the view. Since this is custom I’ve created a view with identical column names to my 3 main parameters and attempted to pass each parameter to the view separately, so far I have been unsuccessful. Does anyone see anything obviously wrong with either the view I’ve created or the set up of my function?

@klincecum @dcamlin

I have also attempted to set the parameters up like this:

Here are the response parameters, I’ve confirmed they are returning successfully using REST API Help:

{
  "EndUser1": "string",
  "EndUser2": "string",
  "FinalDestinationCountry": "string",
  "myExtraOutput": "string"
}

I don’t see the little arrow on that diagram on the function.

Possible the event is corrupt.

I will attempt to rebuild the event then and see where that gets me. I had never noticed that. Looked at another event and sure enough it does have the little arrow.

1 Like

We’ve been having a couple discussions on it lately.

1 Like

As far as the rest, since you said your function was working correctly, I can’t really help.

I abandoned Kinetic in frustration almost a year ago.

I’m just now getting back into it after all the improvements and progress I’ve seen, but I’m having to learn it all over again. :sob:

1 Like

Well I didn’t realize that. I’ve learned a lot from your threads here and you’re always quick to help, so I appreciate it. It is getting better on the front-end and the backend is slowly getting to a place where things are starting to work more as you’d expect.

Overall we’re making it work, but as the one making customizations it has been extremely frustrating at times. Generally I don’t have an explanation for why I can’t get something to work. Thankfully I work with some pretty amazing and flexible people :slightly_smiling_face:

1 Like