Page 1 of 1

AddInventoryItem returning FALSE even though adding line

PostPosted: Mon Apr 26, 2021 10:35 am
by aegean66
Hoping someone might see this and have an idea? The line of code below returns FALSE

But it definitely DOES populate the quote with a new line? I test this after it has executed within a loop and is 100% returning false

ReturnCode = MyJiwaSalesQuote.SalesQuoteLines.AddInventoryItem(vPartNo, 1, NewKey)

Any ideas?

Re: AddInventoryItem returning FALSE even though adding line

PostPosted: Mon Apr 26, 2021 12:06 pm
by Scott.Pearce
AddInventoryItem does not return a boolean. It returns a JiwaSalesQuote.clsSalesQuoteLines.SalesQuoteLineReturnCodes

You are implicitly casting a "JiwaSalesQuote.clsSalesQuoteLines.SalesQuoteLineReturnCodes" type into a boolean type. Don't do this.

Your call should look like this:

Code: Select all
If AddInventoryItem(InvItem.InventoryID, e_SalesQuoteLineInventoryID, NewLineKey, Row + MyLoop) = e_SalesQuoteLineReturnCodeSuccess Then

Re: AddInventoryItem returning FALSE even though adding line

PostPosted: Mon Apr 26, 2021 12:10 pm
by aegean66
Thanks Scott, much appreciated

Wasn't expecting a reply any time soon being JIWA 6 :)

Re: AddInventoryItem returning FALSE even though adding line

PostPosted: Mon Apr 26, 2021 5:03 pm
by aegean66
I think I've been here before, and ended up having to work around it by populating arrays to add lines to quote via SQL (not ideal I know)

The following line of code does NOT work, it gives me a type mismatch error

If MyJiwaSalesQuote.SalesQuoteLines.AddInventoryItem(vPartNo, e_SalesQuoteLinePartNo, NewLineKey) = e_SalesQuoteLineReturnCodeSuccess Then


The following line of code DOES work (adds a line to a quote, but NewLineKey is given no value and remains empty) - Note the use of Chr(NewLineKey) instead of just NewLineKey

If MyJiwaSalesQuote.SalesQuoteLines.AddInventoryItem(vPartNo, e_SalesQuoteLinePartNo, Chr(NewLineKey)) = e_SalesQuoteLineReturnCodeSuccess Then

Re: AddInventoryItem returning FALSE even though adding line

PostPosted: Mon Apr 26, 2021 5:05 pm
by Scott.Pearce
Is this in VBScript?

Re: AddInventoryItem returning FALSE even though adding line

PostPosted: Mon Apr 26, 2021 5:19 pm
by aegean66
Yes, I ended up doing a workaround like this, and it works. Go figure.

If MyJiwaSalesQuote.SalesQuoteLines.AddInventoryItem(vPartNo, e_SalesQuoteLinePartNo, Chr(NewLineKey)) = e_SalesQuoteLineReturnCodeSuccess Then
Else
End If
For Each SalesQuoteLineObject In MyJiwaSalesQuote.SalesQuoteLines
If SalesQuoteLineObject.PartNo = vPartNo Then
SalesQuoteLineObject.QuantityOrdered = vQty
Else
End If
Next