Creating Quote with operations and materials from REST

Hi,
I am trying to create a Quote from REST, that quote will have also engineering on every line. I asked in a previous post about the best approach (WCF or REST) and seemed that REST was the best way to go for this.

However, I have never done this and I been hitting my head hard with it. I saw other posts that indicates that Custom Methods and also people that are doing the same thing as I. I’ve managed to get a simple application to create QuoteHed and QuoteDtl, and I am using the NuGet package from @josecgomez and @jgiese.wci to make life easier. But I am stuck at how to update data from QuoteDtl when I have a second line.

I did it in a customization, but I used DataTable.Select("RowMod=“A”), which in this case shouldn’t be the way to go, since the idea is to dynamically do everything. In REST I simply cheated for the first line addresing it as QuoteDtl[0][“PartNum”] My guess is that I can obtain the correct record with Linq, but I can’t figure out how. I get errors indicating that I can’t use a Lambda expression to a dynamically dispatched operation without first casting it to a delegate or expression tree.

Could you point me into the right direction? Also if there is any recommendation in where I can soak into this more effectively I would love to hear about it. Initially I thought that I had to deserialize the JSON response modify it and then serialize it again, which I am guessing would defeat the actual purpose.

@Evan_Purdy seems to have done it back in 2019 also so if you could share your insights it would be highly appreciated.

Thanks in advance

P.S. Sorry if I seem to newbie about this, I was trying to gather information but it is an specific usage of a broad subject and I got lost several times.

If you just want to do the MOM then Erp.BO.QuoteAsmSvc.GetByID takes quote, line, and assembly number. The easiest way to get a quote line would probably be the OData method on Erp.BO.QuoteSvc – Erp.BO.QuoteSvc/QuoteDtls

1 Like

Thank you, Evan
I’ve thought also in using the OData methods and even believed that would yield a better performance, but I recall issues regarding the unit price and getting all the info loaded. It seemed that some processes are not run unless you update a specific field. Have you done it that way?

Thanks again

I checked my code, I see I am setting DocDspExpUnitPrice, DocExpUnitPrice, and ExpUnitPrice. Seems to work for me. I remember I did have trouble with the price “sticking” at first, but I think once I added all those it worked fine.

1 Like

Thanks again, Evan

Yes, I had to update in the DocDspExpUnitPrice in the customization, along with the EpiNotify back then.

I’ll try with oData for the header and detail then, because I did try with the reference from @josecgomez you referenced, but got an error indicating that Cast was not available for the jarray. So it seems I am not Linq, nor REST fluent enough.

Thank you

Here’s an example of using LINQ with a dynamic object

dynamic ds = EpicorRest.DynamicPost("Erp.BO.CustomerSvc", "GetByCustID", new { custID = outCustID, withShipTo = true });
var exists = ((IEnumerable<dynamic>)ds.ds.ShipTo).Cast<dynamic>().Where(l => l.ShipToNum == shipTo.ShipTo.ToString()).Any();

Thank you, Jose

I just answered before seeing your response.
I get an error, at runtime that says Cast<> is no available for jarray…
Any ideas? Oh, wait, I think I misplaced a parens.

One more newbie question. How do I set the values in that reference? I am trying something like:

IEnumerable x = ((IEnumerable)rData.parameters.ds.QuoteDtl).Cast().Where(l => l.RowMod == “A”).FirstOrDefault();

x.PartNum = “INS00”;

But I get that PartNum is not in the definition. Nor I can reference it by indexing x[0][“PartNum”] for example.

x needs to be dynamic

 var shNum = ((IEnumerable<dynamic>)ds.parameters.ds.ShipTo).Cast<dynamic>().Last();
shNum.ShipToNum = shipTo.ShipTo;
shNum.TerritorySelect = "SYNC";
shNum.sgcApproved_c = true;
shNum.TerritoryID = shipTo.Plant.ToString("000");
1 Like

Thank you!