Scripting

  • 1.  C# syntax issues again:Trying to get the next bat

    Posted 08-28-2018 13:00
    C# syntax issues again: Trying to get the next batch number for SO Invoice entry string sBatchNo = """"; DispatchObject sage = new DispatchObject(pvx.InvokeMethod(""NewObject"", ""SO_Invoice_bus"", oSS.GetObject())); int iBatchEnabled = 0; iBatchEnabled = (int)sage.InvokeMethod(""nBatchEnabled""); if (iBatchEnabled == 1) { retval = (int)sage.InvokeMethod(""nSelectbatch"",sBatchNo); }; response[""BatchNo$""] = sBatchNo; response[""success""] = true; No errors (iBatchEnabelretval = 1), but sBatchNo is still """" at the end of it. Any ideas?


  • 2.  RE: C# syntax issues again:Trying to get the next bat

    Posted 08-28-2018 13:32
    What about: retval = (int)sage.InvokeMethod(""nSelectNewBatch"", sBatchNo, ""N"", ""Batch Comment"");


  • 3.  RE: C# syntax issues again:Trying to get the next bat

    Posted 08-28-2018 13:50
    Unfortunately, same result...


  • 4.  RE: C# syntax issues again:Trying to get the next bat

    Posted 08-28-2018 13:56
    Try breaking your DispatchObject line into 2 separate lines: private DispatchObject sage = null; sage = new DispatchObject(pvx.InvokeMethod(""NewObject"", ""SO_Invoice_bus"", oSS.GetObject()));


  • 5.  RE: C# syntax issues again:Trying to get the next bat

    Posted 08-28-2018 14:08
    still retval = 1 but sBatchNo =


  • 6.  RE: C# syntax issues again:Trying to get the next bat

    Posted 08-28-2018 14:26
    Hmm maybe it needs InvokeMethodByRef instead: object[] params = null; params = new object[] { ""NextBatchNo$"" }; retVal = (int)sage.InvokeMethodByRef(""nSelectBatch"", params); if (retVal == 1) { sBatchNo = params[0].ToString(); } else { errorMsg = ""Error getting Next Batch Number""; throw new Exception(errorMsg); }


  • 7.  RE: C# syntax issues again:Trying to get the next bat

    Posted 08-28-2018 15:52
    retVal = (int)sage.InvokeMethodByRef(""nSelectBatch"", parms); retVal = 0, error message is ""NextBatchNo$ already exists


  • 8.  RE: C# syntax issues again:Trying to get the next bat

    Posted 08-28-2018 15:57
    However if I combine your suggestions I get a working version: parms = new object[] { sBatchNo, ""N"", ""Batch Description"" }; retVal = (int)sage.InvokeMethodByRef(""nSelectNewBatch"", parms); Thank you Alnoor!