Receipt of Invoice adding lines using BOI with multiple POs

SOLVED

Hello,

I have two PO's and one line detail for each. I'm trying to add two lines to the Receipt of Invoice screen using BOI, using Sage 100 v2020 multiple POs. This is a new functionality with their cloud license. I get the header by setting Purchase Order for the two I want, after import it shows Multiple but my details come in only for one line. I noticed after running the script, I do have two rows in the Receipt Details table, but the second line has null for OrderLineKey and thus the invoiced qty and other details don't come through. Does anyone know what I"m missing here?

thanks

' First create ProvideX com object
Set oScript = CreateObject("ProvideX.Script")

'The Init method must be the first method called, and requires the path to the MAS90 home directory
oScript.Init("C:\Sage\Sage 100 Advanced\MAS90\Home")

'NewObject method creates a new MAS 90 Session object and returns the objects reference in oSS
Set oSS = oScript.NewObject("SY_Session")

If retVAL = 0 Then
User = "muUser"
Password = "password"
retVAL = oSS.nSetUser(User,Password)
End If

If retVAL = 0 Then
MsgBox(oSS.sLastErrorMsg)
oSS.nCleanup() ' Call Cleanup() before dropping the Session Object
oSS.DropObject()
Set oSS = Nothing
WScript.Quit
End If

Company = "EEC"
retVAL = oSS.nSetCompany(Company)

If retVAL = 0 Then
MsgBox(oSS.sLastErrorMsg)
oSS.nCleanup() ' Call Cleanup() before dropping the Session Object
oSS.DropObject()
Set oSS = Nothing
WScript.Quit
End If

' Get the Date to pass in with the MAS90 format
strDayOfMonth = Day(Date())
strMonth = Month(Date())
strYear = Year(Date())
YYYYMMDD = "20200528"

' Get the Module to pass in to set the Date
strModule = "P/O"

'The date format for the SetDate method must be YYYYMMDD
retVAL = oSS.nSetDate(strModule, YYYYMMDD)

retVal = oSS.nSetProgram(oSS.nLookupTask("PO_ReceiptOfInvoice_ui"))

Set oPOEntry = oScript.NewObject("PO_Receipt_bus",oSS)
Set oPOEntryLines = oPOEntry.oLines

retVal = oPOEntry.nSetValue("ReceiptType$", "I")
retVal = oPOEntry.nSetValue("APDivisionNo$", "01")

recNo = ""
retVal = oPOEntry.nGetNextNextInvoiceEntryNo(recNo)
retVal = oPOEntry.nSetKeyValue("ReceiptNo$", recNo)

retVal = oPOEntry.nSetKey()
If not(CBool(retVal)) Then MsgBox "SetKey Err: " & oPOEntry.sLastErrorMsg

retVal = oPOEntry.nSetValue("InvoiceDate$", "20200528")
retVal = oPOEntry.nSetValue("PurchaseOrderNo$", "0000184")
retVal = oPOEntry.nSetValue("PurchaseOrderNo$", "0000185")
retVal = oPOEntry.nSetValue("InvoiceNo$", "01YM12")
retVal = oPOEntry.nSetValue("MultiplePurchaseOrdersApplied$", "Y")

retVal = oPOEntryLines.nAddLine()
retVal = oPOEntryLines.nSetValue("ReceiptType$", "I")
retVal = oPOEntryLines.nSetValue("ItemCode$", "#12 INDOOR")
retVal = oPOEntryLines.nSetValue("LineKey$", "000001")
retVal = oPOEntryLines.nSetValue("OrderLineKey$", "000001")
retVal = oPOEntryLines.nSetValue("AppliedPurchaseOrderNo$", "0000184")
retVal = oPOEntryLines.nSetValue("UnitCost", .20)
retVal = oPOEntryLines.nSetValue("QuantityInvoiced", 4)
retVal = oPOEntryLines.nWrite()
If not(CBool(retVal)) Then MsgBox "Lines.Write Err: " & oPOEntryLines.sLastErrorMsg

retVal = oPOEntryLines.nAddLine()
retVal = oPOEntryLines.nSetValue("ReceiptType$", "I")
retVal = oPOEntryLines.nSetValue("ItemCode$", "#12 INDOOR")
retVal = oPOEntryLines.nSetValue("LineKey$", "000002")
retVal = oPOEntryLines.nSetValue("OrderLineKey$", "000001")
retVal = oPOEntryLines.nSetValue("AppliedPurchaseOrderNo$", "0000185")
retVal = oPOEntryLines.nSetValue("UnitCost", .20)
retVal = oPOEntryLines.nSetValue("QuantityInvoiced", 20)
retVal = oPOEntryLines.nWrite()
If not(CBool(retVal)) Then MsgBox "Lines.Write Err: " & oPOEntryLines.sLastErrorMsg

'write the header
retVal = oPOEntry.nWrite()
If not(CBool(retVal)) Then MsgBox "Header write Err: " & oPOEntry.sLastErrorMsg

MsgBox ("Done")