Create quoteline throu CS

Hi,

Ive noticed that R&D fixed the bug where the NSQuote class would crash when loading it, so we are off to the races with developing some new CS -> Quote functions.

Creating a quote works just fine, but im not able to create a quoteline.

Anyone got a snippet for this, or can spot any errors withing the follow codesnippet?

#setLanguageLevel 3;

NSQuoteAgent MyAgent;

NSQuoteEntity MyNewQuote = MyAgent.CreateAndSaveQuote(6,1,"Produkter");

NSQuoteLine MyNewQuoteLine = MyAgent.CreateQuoteLine(95,"SUO_95");

MyNewQuoteLine.SetQuantity(2.0);
MyNewQuoteLine.SetRank(1);
MyNewQuoteLine.SetUnitListPrice(123.2);
MyNewQuoteLine.SetPriceUnit("St");
MyNewQuoteLine.SetTotalPrice(10.0);
MyNewQuoteLine.SetName("TAG Heuer Aquaracer Black Dial Bracelet");
MyNewQuoteLine.SetCode("WAN2110.BA0822");

MyNewQuoteLine.SetERPProductKey("SUO_95");
MyNewQuoteLine.SetProductTypeKey("1");
MyNewQuoteLine.SetProductFamilyKey("1");
MyNewQuoteLine.SetProductCategoryKey("1");
MyNewQuoteLine.SetQuoteAlternativeId(1);



MyAgent.SaveQuoteLine(MyNewQuoteLine);

It will result in the following error:

Exception running script: EjScript::RunTimeException: An exception occurred in script: "" at: line 25, char 13
    MyAgent.SaveQuoteLine(MyNewQuoteLine);
------------^

Original exception: NetServerException:
NetServer exception: Service call failed with exception
Quote.SaveQuoteLine

Sequence contains no matching element

RE: Create quoteline throu CS

Hi Pär,

Not an answer to your question, but... What happens if you run the same type of code in .NET (using the QuoteAgent and the same methods)? Do you get the same error?

Maybe you are able to debug and dissect more of the Web Service call there and find the underlying error?

When you have found your way, you can try to implement the corresponding adjustment in EJscript again.

More of a debugging method rather than an explicit solution, but hope it might help you get further. :)

Von: Marcus Svenningsson 12. Mai 2017

RE: Create quoteline throu CS

Sorry but no, not really.

There is no problem at all creating quotelines in .NET service using the same principal of coding.

And the data added a copy of an already existing productrow so it should be alright.

 

What i need to know is, what does Sequence contains no matching element mean, what is missing?

Von: Pär Pettersson 12. Mai 2017

RE: Create quoteline throu CS

Hi Pär, did you figure out what caused the "Sequence contains no matching element" error when creating a quoteline? I'm getting the same here...

Von: Frode Lillerud 17. Nov 2018

RE: Create quoteline throu CS

Hi Frode,
Yes i fixed it, but i really cant remeber now.


Im currently on parental leave, but if i start up the work computer in the next few days i´ll send a snippet of the working solution.

Regards

Von: Pär Pettersson 20. Nov 2018

RE: Create quoteline throu CS

That's OK, I got around it. Don't remember what I did either...

Von: Frode Lillerud 20. Nov 2018

RE: Create quoteline throu CS

This error message keeps popping up from time to time, so i will make this post to keep track of what solved it everytime since i always comes back to this thread.

Possible reasons:
1. The sale is connected to an ERPConnection that missmatch the products.
2. Missing fields, for example Quantity

Von: Pär Pettersson 9. Sep 2019