Scripting

  • 1.  I am working on a script to create AP Invoice Adju

    Posted 01-06-2017 08:22
    I am working on a script to create AP Invoice Adjustments. Batches are enabled. I have a need to get the batch handle and have the following line of code... Set batch_handle = oBusObj.nGetBatchHandle() This line is generating an 'Object Required' error ... I seem to recall that may need to wrap this call in a function to cast the return value as an object for vbs... apparently, I thinned out too many brain cells over the holidays since I cannot recall how to make this happen... anybody remember?


  • 2.  RE: I am working on a script to create AP Invoice Adju

    Posted 01-06-2017 08:39
    You probably need the lookup object as the parameter. Are you trying to pop the Batch Manager up for the user to create? I usually use SelectNewBatch to create the next or SelectBatch to find an existing.


  • 3.  RE: I am working on a script to create AP Invoice Adju

    Posted 01-06-2017 08:54
    No, not trying to to do that, this installation has a modification to A/P batches. An additional field has been added (AccountingDate$) to the object. I need to set the value of this field and naturally, need the object handle to do it.


  • 4.  RE: I am working on a script to create AP Invoice Adju

    Posted 01-06-2017 09:08
      |   view attached
    The Object Reference says you'll need the SY_BatchManagerSelect_UI handle.


  • 5.  RE: I am working on a script to create AP Invoice Adju

    Posted 01-06-2017 09:17
    I just discovered that as well... I don't want any UI in this process... oBusObj.nSelectNewBatch() creates the batch for me just fine.... and does not provide me with the any UI object handles.... so it seems I need another object handle that I do not have... I seem to be getting farther from my goal rather than closer....


  • 6.  RE: I am working on a script to create AP Invoice Adju

    Posted 01-06-2017 10:30
    If that field is in the data dictionary, you might still be able to SetValue thru oBusObj.


  • 7.  RE: I am working on a script to create AP Invoice Adju

    Posted 03-26-2017 08:33
    The following may work for you, i adapted some code i had testing AR invoices. There may be a better way but this worked for me during a brief test. I tested this with and without initializing the session UI object. As long as you don't ""process"" the invoice UI object, you should not have a ""UI"" appear. '----------------------------------------------------------------------- Set oShell = CreateObject(""WScript.Shell"") sPath = """" : sPath = oShell.RegRead(""HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\SOTAMAS90\Directory"") Set oPVXSession = CreateObject (""ProvideX.Script"") oPVXSession.Init(sPath & ""\Home"") ' Make sure to set this path to point to the mas90 folder on the server Set oSS = oPVXSession.NewObject(""SY_Session"") nRetval = oSS.nInitiateUI() Set oUI = oSS.oUI 'on error resume next Set oScript = oSS.ScriptObject nRetval = oSS.nSetUser(""user"", ""password"") ' Make sure to specify credentials sCompanyCode = ""ABC"" sModuleCode = ""A/R"" sModuleDate = ""20200527"" nRetval = oSS.nSetCompany(sCompanyCode) nRetval = oSS.nSetDate(sModuleCode, sModuleDate) nRetval = oSS.nSetModule(sModuleCode) oSS.nSetProgram(oSS.nLookupTask(""AR_Invoice_ui"")) Set oAR_Invoice_ui = oPVXSession.NewObject(""AR_Invoice_ui"", oSS) Set oAR_Invoice_bus = oAR_Invoice_ui.ocoHeader Set oAR_BatchHandle_ui = oAR_Invoice_ui.oBatchUIObj Set oAR_BatchHandle_bus = oAR_BatchHandle_ui.ocoBusiness sNextBatchNo = """" nRetval = oAR_BatchHandle_bus.nOpenNextBatch(sNextBatchNo) sRetval = oUI.sMessageBox("""", ""Next Batch Number: "" & sNextBatchNo & vbCrLf & oAR_BatchHandle_bus.sLastErrorMsg & vbCrLf & nRetval) sBatchKey = oAR_BatchHandle_bus.sGetKeyPadded() sRetval = oUI.sMessageBox("""", ""Current Key: "" & sKey & vbCrLf & oAR_BatchHandle_bus.sLastErrorMsg) nRetval = oAR_BatchHandle_bus.nSetKey(sBatchKey) ' Not sure why but if this is a brand new batch and you don't call the ""SetKey"" method, the ""write"" method fails with the error ""the record is not in an editable state"". sRetval = oUI.sMessageBox("""", ""Set Key: "" & nRetval & vbCrLf & oAR_BatchHandle_bus.sLastErrorMsg) nRetval = oAR_BatchHandle_bus.nSetValue(""Comment$"", ""Test"") sRetval = oUI.sMessageBox("""", ""Set Batch Comment: "" & nRetval & vbCrLf & oAR_BatchHandle_bus.sLastErrorMsg) nRetval = oAR_BatchHandle_bus.nWrite() sRetval = oUI.sMessageBox("""", ""Write Batch Comment: "" & nRetval & vbCrLf & oAR_BatchHandle_bus.sLastErrorMsg) nRetval = oAR_Invoice_bus.nSelectBatch(sNextBatchNo) sRetval = oUI.sMessageBox("""", ""Select Batch: "" & nRetval & vbCrLf & oAR_Invoice_bus.sLastErrorMsg & vbCrLf & sBatch) sNextInvoiceNo = """" nRetval = oAR_Invoice_bus.nGetNextInvoiceNo(sNextInvoiceNo) sRetval = oUI.sMessageBox("""", ""Get Next Invoice No: "" & nRetval & vbCrLf & oAR_Invoice_bus.sLastErrorMsg & vbCrLf & sNextInvoiceNo) nRetval = oAR_Invoice_bus.nSetKeyValue(""InvoiceNo$"", sNextInvoiceNo) nRetval = oAR_Invoice_bus.nSetKeyValue(""InvoiceType$"", ""IN"") nRetval = oAR_Invoice_bus.nSetKey() sRetval = oUI.sMessageBox("""", ""Set Header Key: "" & nRetval & vbCrLf & oAR_Invoice_bus.sLastErrorMsg) '-----------------------------------------------------------------------


  • 8.  RE: I am working on a script to create AP Invoice Adju

    Posted 03-27-2017 07:38
    @RandyMarion , I use this command in VI preform logic to set a batch. It will create the batch record if needed. If NOT(NUL(var$)) { coBusiness'SelectBatch(var$) }