How to get AP Invoices and their remaining balance amount

SUGGESTED

I would like to get a list of of AP invoices and their remaining balance.  I am using "AP_OpenInvoice_bus" but the amounts do not seem to be returned when using GetResultSets.  Below is  the column string I am using.  Any ideas or perhaps I am using the wrong bus object.

"APDivisionNo$+\",\"+VendorNo$+\",\"+InvoiceNo$+\",\"+InvoiceDate$+\",\"+InvoiceDueDate$+\",\"+InvoiceDiscountDate$+\",\"+InvoiceHistoryHeaderSeqNo$+\",\"+PostingDate$+\",\"+TermsCode$+\",\"+HoldPayment$+\",\"+Comment$+\",\"+WireTransferNo$+\",\"+JobNo$+\",\"+CheckNo$+\",\"+CheckType$+\",\"+CheckDate$+\",\"+PaidToday$+\",\"+Form1099$+\",\"+Box1099$+\",\"+SeparateCheck$+\",\"+TaxSchedule$+\",\"+TaxClass$+\",\"+UseTax$+\",\"+InvoiceAmt$+\",\"+DiscountAmt$+\",\"+RetentionCost$+\",\"+Balance$+\",\"+TaxableAmt$+\",\"+NonTaxableAmt$+\",\"+FreightAmt$+\",\"+TaxAmt$+\",\"+NonRecoverableAmt$+\",\"+DateCreated$+\",\"+TimeCreated$+\",\"+UserCreatedKey$+\",\"+DateUpdated$+\",\"+TimeUpdated$+\",\"+UserUpdatedKey$"

  • 0
    I put together the below sample c# that demonstrates my results. I am using the DispatchObject that is commonly used in this forum. I am not getting the Balance returned or any of the amount fields for that matter. Perhaps there is a better way to do this or that I am going about this all wrong.



    DateTime date = DateTime.Now;
    string path = @"C:\Sage\Sage 100 Standard\MAS90\Home";
    string username = "USERNAME";
    string password = "PASSWORD";
    string company = "ABC";
    string busName = "AP_OpenInvoice_bus";
    string moduleName = "A/P";
    string programName = "AP_OpenInvoicesView_UI";
    string strResult = string.Empty;
    string strJunk = string.Empty;
    string strColumns = string.Empty;
    string strKeys = string.Empty;
    string strFilter = string.Empty;
    string strBeginKey = string.Empty;
    string strEndKey = string.Empty;


    using (DispatchObject script = new DispatchObject("ProvideX.Script"))
    {
    script.InvokeMethod("Init", path);

    using (DispatchObject session = new DispatchObject(script.InvokeMethod("NewObject", "SY_Session")))
    {
    session.InvokeMethod("nInitiateUI");
    session.InvokeMethod("nLogon");
    session.InvokeMethod("nSetUser", username, password);
    session.InvokeMethod("nSetCompany", company);
    session.InvokeMethod("nSetModule", "SYS");
    session.InvokeMethod("nSetDate", "SYS", date.ToString("MMddyyyy"));

    session.InvokeMethod("nSetModule", moduleName);
    session.InvokeMethod("nSetProgram", session.InvokeMethod("nLookupTask", programName));
    using (DispatchObject bus = new DispatchObject(script.InvokeMethod("NewObject", busName, session.GetObject())))
    {
    strColumns = "APDivisionNo$+\",\"+VendorNo$+\",\"+InvoiceNo$+\",\"+InvoiceDate$+\",\"+InvoiceDueDate$+\",\"+InvoiceDiscountDate$+\",\"+InvoiceHistoryHeaderSeqNo$+\",\"+PostingDate$+\",\"+TermsCode$+\",\"+HoldPayment$+\",\"+Comment$+\",\"+WireTransferNo$+\",\"+JobNo$+\",\"+CheckNo$+\",\"+CheckType$+\",\"+CheckDate$+\",\"+PaidToday$+\",\"+Form1099$+\",\"+Box1099$+\",\"+SeparateCheck$+\",\"+TaxSchedule$+\",\"+TaxClass$+\",\"+UseTax$+\",\"+InvoiceAmt$+\",\"+DiscountAmt$+\",\"+RetentionCost$+\",\"+Balance$+\",\"+TaxableAmt$+\",\"+NonTaxableAmt$+\",\"+FreightAmt$+\",\"+TaxAmt$+\",\"+NonRecoverableAmt$+\",\"+DateCreated$+\",\"+TimeCreated$+\",\"+UserCreatedKey$+\",\"+DateUpdated$+\",\"+TimeUpdated$+\",\"+UserUpdatedKey$";
    strKeys = "InvoiceNo$";

    object[] getResultSetParams = new object[] { strColumns, strKeys, strResult, strJunk, strFilter, strBeginKey, strEndKey };

    bus.InvokeMethodByRef("nGetResultSets", getResultSetParams);

    strResult = getResultSetParams[2].ToString();
    }

    session.InvokeMethod("DropObject");
    }
    }
  • 0 in reply to MartinHenderson
    SUGGESTED
    I figured it out. If the column data is not a string it is not returned unless you cast it to one. So in order to get the balance I needed to use "+STR(Balance)+" instead of "+Balance$+". Once I did this the values were returned in my result string.