Missing record to calculate taxes

I am getting this error "Missing record to calculate taxes." while trying to import Sales order in Sage using BOI.

Has anybody faced this issue before? OR anyone has some idea how to solve this.

Appreciated your help

  • Which objects are you using?

    Which fields are you setting?

    Are you sure the message is an error and not a warning (you need to check the actual returned value of the methods like SetKey and Write to determine this)?

  • in reply to David Speck

    @David Speck. i am trying to create an order. My code is as shown below

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

     

     

    namespace SkynamoSage100Integration

    {

        class Program

        {

            static void Main(string[] args)

            {

     

                Console.WriteLine("Attempting login and create session");

     

     

               

                

     

                using (DispatchObject pvx = new DispatchObject("ProvideX.Script"))

                {

                    pvx.InvokeMethod("Init", @"C:\Sage\Sage 100 Advanced\MAS90\Home");

                    using (DispatchObject oSS = new DispatchObject(pvx.InvokeMethod("NewObject", "SY_Session")))

                    {

     

                        oSS.InvokeMethod("nSetUser", "test", "test");

     

                        oSS.InvokeMethod("nSetCompany", "ABC");

                        oSS.InvokeMethod("nLogon");

                        oSS.InvokeMethod("nSetModule", "S/O");

                        oSS.InvokeMethod("nSetDate", "S/O", "02252021");

     

                        Console.WriteLine("session created and login was successful!!");

     

                        int TaskID = (int)oSS.InvokeMethod("nLookupTask", "SO_SalesOrder_ui");

                        oSS.InvokeMethod("nSetProgram", TaskID);

     

                        using (DispatchObject ordeR = new DispatchObject(pvx.InvokeMethod("NewObject", "SO_SalesOrder_bus", oSS.GetObject())))

                        {

     

                            //string strSalesOrderNo = "";

                            //object[] getNextOrd = new object[] { strSalesOrderNo };

                            //ordeR.InvokeMethodByRef("nGetNextSalesOrderNo", getNextOrd);

                            //Console.WriteLine(getNextOrd);

                            //Console.ReadKey();

                            //ordeR.InvokeMethod("nSetKey", getNextOrd.ToString());

     

                            string error1 = (string)ordeR.GetProperty("sLastErrorMsg");

                            ordeR.InvokeMethod("nSetValue", "SalesOrderNo$", "0000300");

                            ordeR.InvokeMethod("nSetValue", "ARDivisionNo$", "02");                         

                            ordeR.InvokeMethod("nSetValue", "CustomerNo$", "JELLCO");

                            string error2 = (string)ordeR.GetProperty("sLastErrorMsg");

     

                            //string error3 = (string)ordeR.GetProperty("sLastErrorMsg");

                            ordeR.InvokeMethod("nSetValue", "PrintSalesOrders$", "N");

                            ordeR.InvokeMethod("nSetValue", "PrintPickingSheets$", "N");

                            ordeR.InvokeMethod("nSetValue", "TermsCode$", "02");

     

                            using (DispatchObject soLine = new DispatchObject(ordeR.GetProperty("oLines")))

                            {

                                soLine.InvokeMethod("nAddLine");

                                soLine.InvokeMethod("nSetValue", "ItemCode$", "HON 2 DRAWER FLE W/ LCK");

                                soLine.InvokeMethod("nSetValue", "QuantityOrdered", "10");

                                soLine.InvokeMethod("nWrite");

                                string error4 = (string)ordeR.GetProperty("sLastErrorMsg");

     

     

                                ordeR.InvokeMethod("nWrite");

                                Console.WriteLine("order could not be added due to error\n" + error1 + "\n" + error2 + "\n" + error4);

                                Console.ReadKey();

                            }

     

                        }

                    }

                }  

            }

        }

    }

  • in reply to Tatenda Mugadza

    You are using SetValue for the SalesOrderNo$ field.  All single field keys should use SetKey to put the record in an editable state.  For multi-part keys, you should use SetKeyValue for each field followed by a SetKey without any arguments.

  • in reply to Tatenda Mugadza

    Also, your Logon method is not needed if you are using SetUser.

    Date fields are in the YYYYMMDD format, you are setting the date in the SetDate mehtod using what appears to be in the MMDDYYYY format.

  • in reply to David Speck

    Hi David Speck. Please may you kindly give examples of what you mean here, I am not sure I understand what you mean

  • in reply to Tatenda Mugadza

    Here I mean examples of the setKey and SetValue use cases

  • in reply to Tatenda Mugadza

    If you haven't already, familiarize yourself with Sage 100 File Layouts and Object Reference - Sage 100 File Layouts and Object Reference.

    Use it to review tables and their keys and indexes.

    When a table's primary index's key is only comprised of one field, you can use the SetKey method and pass it the key you are trying to edit.  However, if it is comprised of more than one field, you have two options, either pad all fields to their max length with a null character (ASCII # 0) with the exception of the last field that makes up the key when passing it to the or use the SetKeyValue method for each field that makes up the key, you then follow this with the SetKey method without an argument.  The first argument for SetKeyValue is the field, much like SetValue, the second argument is the value.

    The following is an example of a single field key like SO_SalesOrderHeader
    nRetVal = 0 : nRetVal = oBusObj.SetKey("1234567")

    The following is an example of a multi field key like AR_Customer
    oBusObj.SetKeyValue "ARDivisionNo$", "00"
    oBusObj.SetKeyValue "CustomerNo$", "1234567"
    nRetVal = 0 : nRetVal = oBusObj.SetKey()

  • in reply to David Speck

    David,

    I'm experiencing similar issue as the original poster 

    retVal = oSOOrder.oLines.nAddLine()
    retVal = oSOOrder.oLines.nSetValue("ItemCode$", "44241")

    If retVal = 0 Then

    msgVal = oSOOrder.sLastErrorMsg
    errCode = 0
    errMsg = errMsg & "|Error Setting SKU: " + msgVal
    WScript.Echo(errCode & errMsg)

    oSS.nCleanup()
    oSS.DropObject()
    Set oss = Nothing
    Set oScript = Nothing

    WScript.Quit
    End If

    retVal = oSOOrder.oLines.nSetValue("ItemType$", "1")

    If retVal = 0 Then

    msgVal = oSOOrder.sLastErrorMsg
    errCode = 0
    errMsg = errMsg & "|Error Setting Description: " + msgVal
    WScript.Echo(errCode & errMsg)

    oSS.nCleanup()
    oSS.DropObject()
    Set oss = Nothing
    Set oScript = Nothing

    WScript.Quit
    End If

    retVal = oSOOrder.oLines.nSetValue("WarehouseCode$", "WEB")

    If retVal = 0 Then

    msgVal = oSOOrder.sLastErrorMsg
    errCode = 0
    errMsg = errMsg & "|Error Setting Warehouse Code on Item: " + msgVal
    WScript.Echo(errCode & errMsg)

    oSS.nCleanup()
    oSS.DropObject()
    Set oss = Nothing
    Set oScript = Nothing

    WScript.Quit
    End If

    retVal = oSOOrder.oLines.nSetValue("UnitOfMeasure$", "EACH")

    If retVal = 0 Then

    msgVal = oSOOrder.sLastErrorMsg
    errCode = 0
    errMsg = errMsg & "|Error Setting Unit Of Measure: " + msgVal
    WScript.Echo(errCode & errMsg)

    oSS.nCleanup()
    oSS.DropObject()
    Set oss = Nothing
    Set oScript = Nothing

    WScript.Quit
    End If

    retVal = oSOOrder.oLines.nSetValue("TaxClass$", "NT")

    If retVal = 0 Then

    msgVal = oSOOrder.sLastErrorMsg
    errCode = 0
    errMsg = errMsg & "|Error Setting Tax Class: " + msgVal
    WScript.Echo(errCode & errMsg)

    oSS.nCleanup()
    oSS.DropObject()
    Set oss = Nothing
    Set oScript = Nothing

    WScript.Quit
    End If

    retVal = oSOOrder.oLines.nSetValue("DropShip$", "N")

    If retVal = 0 Then

    msgVal = oSOOrder.sLastErrorMsg
    errCode = 0
    errMsg = errMsg & "|Error Setting Drop Ship: " + msgVal
    WScript.Echo(errCode & errMsg)

    oSS.nCleanup()
    oSS.DropObject()
    Set oss = Nothing
    Set oScript = Nothing

    WScript.Quit
    End If


    retVal = oSOOrder.oLines.nSetValue("QuantityOrdered", 5.00000)

    If retVal = 0 Then

    msgVal = oSOOrder.sLastErrorMsg
    errCode = 0
    errMsg = errMsg & "|Error Setting Quantity On Order: " + msgVal
    WScript.Echo(errCode & errMsg)

    oSS.nCleanup()
    oSS.DropObject()
    Set oss = Nothing
    Set oScript = Nothing

    WScript.Quit
    End If

    retVal = oSOOrder.oLines.nSetValue("QuantityShipped", 0)

    If retVal = 0 Then

    msgVal = oSOOrder.sLastErrorMsg
    errCode = 0
    errMsg = errMsg & "|Error Setting Quantity Shipped: " + msgVal
    WScript.Echo(errCode & errMsg)

    oSS.nCleanup()
    oSS.DropObject()
    Set oss = Nothing
    Set oScript = Nothing

    WScript.Quit
    End If

    retVal = oSOOrder.oLines.nSetValue("UnitPrice", 2.14000)

    If retVal = 0 Then

    msgVal = oSOOrder.sLastErrorMsg
    errCode = 0
    errMsg = errMsg & "|Error Setting Unit Price: " + msgVal
    WScript.Echo(errCode & errMsg)

    oSS.nCleanup()
    oSS.DropObject()
    Set oss = Nothing
    Set oScript = Nothing

    WScript.Quit
    End If

    retVal = oSOOrder.oLines.nSetValue("Discount$", "Y")
    retVal = oSOOrder.oLines.nWrite()

    If retVal = 0 Then

    msgVal = oSOOrder.sLastErrorMsg
    errCode = 0
    errMsg = errMsg & "|Error writing order entry " + msgVal
    WScript.Echo(errCode & errMsg)

    It got caught on the last error when writing the sales order saying it's missing record to calculate taxes.

  • in reply to TonyCah

    You can't write to Lines without first using a successful SetKey on the header object, which should be oSOOrder based on your code sample.