I am creating batches with the following code (the actual journal entries I won't include because there are obviously many with a zBatch): If oGLGeneralJournal.nBatchEnabled = 1 Then retVal = oGLGeneralJournal.nSelectNewBatch( "3001" , "Y" , "zBatch from nChannel" ) End If retVal = oGLGeneralJournal.nSetKeyValue( "SourceJournal$" , "W8" ) retVal = oGLGeneralJournal.nSetKeyValue( "EntryNo$" , "000035" ) retVal = oGLGeneralJournal.nSetKey() If retVal = 0 Then errCode = 0 errMsg = "|Failed to set key" WScript.Echo(errCode & errMsg) oGLGeneralJournal.DropObject() oSS.nCleanup() oSS.DropObject() Set oGLGeneralJournal = Nothing Set oss = Nothing Set oScript = Nothing WScript.Quit End If retVal = oGLGeneralJournal.nSetValue( "PostingDate$" , "20131111" ) retVal = oGLGeneralJournal.nSetValue( "JournalComment$" , "" ) retVal = oGLGeneralJournal.nSetValue( "AcceptOutOfBalance$" , "Y" ) retVal = oGLGeneralJournal.nSetValue( "BatchNo$" , "3001" ) **** Lots of entries here **** retVal = oGLGeneralJournal.nWrite() If retVal = 0 Then errCode = 0 retVal = oGLGeneralJournal.nDeleteBatch( "3001" ) End If errMsg = errMsg & "|" & oGLGeneralJournal.sLastErrorMsg So the batch gets created even if oGLGeneralJournal.nWrite() fails, so I want to delete the batch in the case of the entries being out of balance, but when I call oGLGeneralJournal.nDeleteBatch("3001") the last error message is "This entry already exists in batch" and the batch is not deleted. I know the batch already exists, if that is what it is referring to, that is why I want to delete it.
↧