Perhaps a GetResultSets would be a better way to handle this.
Here is a link to a good example of it
https://sagecity.na.sage.com/support_communities/sage100_erp/f/sage-100-business-object-interface/71048/advanced-getresultsets
A run down of how i might do this would be the following.
---------------------------------------------------------------------
sSalesOrder = """" : sPymtType = """" : nAuthAmt = 0 : sAuthNo = """"
retVal = oBusObj.GetValue(""SalesOrderNo$"", sSalesOrder)
retVal = oBusObj.GetValue(""PaymentType$"", sPymtType)
If sPymtType = ""AMEX"" Or sPymtType = ""DISC"" Or sPymtType = ""MC"" Or sPymtType = ""VISA"" Then
Set oPayment = oBusObj.AsObject(oBusObj.PaymentObj)
sPaymentSeqNumbers = """"
sPaymentKeys = """"
sFilter = ""CreditCardAuthorizationNo$ = """""""" OR TransactionAmt = 0""
sBegin = sSalesOrder
sEnd = sSalesOrder & Chr(254)
nInvalidPaymentFound = 0
nInvalidPaymentFound = oPayment.GetResultSets(""PaymentSeqNo$"", ""SalesOrderNo$+PaymentSeqNo$"", sPaymentSeqNumbers, sPaymentKeys, sFilter, sBegin, sEnd)
' if nInvalidPaymentFound equals 1, then this means one or more records were found where there was a match to the filter we specified, CreditCardAuthorizationNo$ = """" OR TransactionAmt = 0, the sPaymentSeqNumbers variable will contain a SEP delimited string of the PaymentSeqNo values. sPaymentKeys will contain the combined primary key for each record found that matches.
If nInvalidPaymentFound = 1 Then
sMsg = ""A Credit Card Authorization is Required""
retVal = oScript.SetError(sMsg)
End If
End If
---------------------------------------------------------------------
@AlnoorCassim, it's been a while since i dealt with the Begin and End parameter with GetResultSets and i could not remember the best way to do it off the top of my head, In the above scenario where the records have a multi-part key and we only know the first part, should the Begin end with the CHR(0) character in the same way the End ends with the CHR(254) character or would Amber be better off using just the sSalesOrder variable in the Begin and End parameter?