GetNewQuoteHed fails

I am trying to get Epicor 10.1.400.18 to retrieve a new quote number from an external application. When I run this code in the external application, the GetNewQuoteHed method fails with this error:

Application Error

Exception caught in: Erp.Adapters.Quote

Error Detail

Message: Unable to cast object of type ‘Ice.Core.Session’ to type ‘Ice.Lib.Framework.ILaunch’.
Program: Erp.Adapters.Quote.dll
Method: get_quoteData

Client Stack Trace

at Erp.Adapters.QuoteAdapter.get_quoteData()
at Erp.Adapters.QuoteAdapter.GetNewQuoteHed()

The code is:

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim QNUM As Integer = 0
Dim CustID As String = “2305”
Dim epiSession = New Ice.Core.Session(“Manager”, “manager”, “”, Ice.Core.Session.LicenseType.Default, “C:\Epicor10\Client\config\ERP10.1.sysconfig”, False, “DTSF”, “MfgSys”)
Dim custBO As Erp.Adapters.QuoteAdapter = New Erp.Adapters.QuoteAdapter(epiSession)
If custBO.BOConnect() Then
Dim gotHead As Boolean
gotHead = custBO.GetNewQuoteHed()
If gotHead = True Then
custBO.QuoteData.QuoteHed.Rows(0)(“CustomerCustID”) = CustID
custBO.GetCustomerInfo()
custBO.Update()
QNUM = custBO.QuoteData.QuoteHed.Rows(0)(“QuoteNum”)
Else
MsgBox(“Could not retrieve new Quote Head”)
End If
Else
MsgBox(“Could not connect to BO”)
End If
TextBox1.Text = "QuoteNumber = " & QNUM.ToString()
End Sub
End Class

I would follow this post, while not the same it will provide the insight to be able to fix the issue. @josecgomez has a couple good points in this post around WCF or Rest.

1 Like

I’ll try to post some sample visual studio code I use tomorrow

Here’s how I instanciate an ILaunch

  using (Session  = new Ice.Core.Session("user", "pass", Session.LicenseType.GlobalUser, @"C:\Epicor\ERP10.1Client\Client\config\E10LiveDB2.sysconfig"))
            {
                ILauncher oTrans = new ILauncher(epiSession);
                 //Do Epicor stuff here
                 //Use the ILauncher like oTrans --- JobAsmSearchAdapter joa = new JobAsmSearchAdapter(oTrans);
    }

``

For you it may be something like oTrans as ILauncher = new ILauncher(epiSession)
Class is found in Ice.Framework fyi

These suggestions will work… however keep in mind Dll dependency and having to pass in the config file, plus consuming those licenses (make sure you are releasing them at the end etc…)
Most of these issues are avoided if you use the web services or REST. (As the examples provided before) Since you are having to tinker with it anyways I highly recommend you use the web services or REST and save yourself some headaches.

2 Likes

This worked. Thanks Chris! For anyone else, here is the code in Visual Basic:

These are the references I added:

Erp.Contracts.Bo.Quote.dll
Ice.Lib.EpiClientLib.dll
Erp.UI.QuoteEntry.dll
Erp.Adapters.Quote.dll
Ice.Core.Session


Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim QNUM As Integer = 0
        Dim CustID As String = "2305"
        Dim epiSession = New Ice.Core.Session("userID", "pwd", "", Ice.Core.Session.LicenseType.Default, "C:\Epicor10\Client\config\ERP10.1.sysconfig", False, "cmpny", "plant")
        Dim oTrans As Ice.Lib.Framework.ILauncher = New Ice.Lib.Framework.ILauncher(epiSession)
        Dim custBO As Erp.Adapters.QuoteAdapter = New Erp.Adapters.QuoteAdapter(oTrans)
        If custBO.BOConnect() Then
            Dim gotHead As Boolean
            gotHead = custBO.GetNewQuoteHed()
            If gotHead = True Then
                custBO.QuoteData.QuoteHed.Rows(0)("CustomerCustID") = CustID
                custBO.GetCustomerInfo()
                custBO.Update()
                QNUM = custBO.QuoteData.QuoteHed.Rows(0)("QuoteNum")
            Else
                MsgBox("Could not retrieve new Quote Head")
            End If
        Else
            MsgBox("Could not connect to BO")
        End If
        TextBox1.Text = "QuoteNumber = " & QNUM.ToString()
        TextBox1.Update()
    End Sub
End Class
1 Like

Does WCF work in 10.1.400.18? Does REST? WCF looks like there is a lot of setup involved. We will investigate further. I value your input. If you had to choose, which one would you use in 10.1.400.18 and beyond?

REST isn’t alive until 500 as a TECH PREVIEW and in 600 it’s LIVE. Glad this got you going.

And for the record, always take @josecgomez’s advice over mine :smile:

Also I’d like to note a cool feature you can use on the forum for displaying code

> ```cs
> YOUR CODE
> ```
1 Like

WCF works on any version of 10, I would go with WCF if REST isn’t available. There is a WCF How To Guide in Epic Web that walks you through how to implement it as well as examples in the posts outlined above.

https://epicweb.epicor.com/doc/Docs/Epicor10_techrefWCFServices_101400.pdf

Anything above 500 I’d recommend REST

But, for the record… there isn’t anything wrong with the example that you and @Chris_Conn are working on, as a matter of Fact the adapters are nothing but implementations of the WCF Proxies. The only downside as I stated is that you create version dependency because you are using the DLL’s and the possibility of having rouge Session if you don’t dispose them properly.
The trade off is maintenance down the road being more difficult or putting a bit of effort now to have easier time upgrading in the future :slight_smile:

1 Like

I am currently trying C# and WCF. Someone shoot me now …

I’m downloading the document referenced above.

Thanks for the help guys!

JPS

3 Likes

While not as complete, did you see the integration examples post I made up here a few weeks ago?

I hope to fill in a better overview of all options in the 10.2 release with appropriate examples.

2 Likes