AddInventoryItem returning FALSE even though adding line

Discussions relating to breakout scripting, .NET and COM programming with Jiwa objects.

AddInventoryItem returning FALSE even though adding line

Postby aegean66 » Mon Apr 26, 2021 10:35 am

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?
aegean66
Occasional Contributor
Occasional Contributor
 
Posts: 36
Joined: Wed Mar 02, 2011 2:26 pm
Topics Solved: 2

Re: AddInventoryItem returning FALSE even though adding line

Postby Scott.Pearce » Mon Apr 26, 2021 12:06 pm

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
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: AddInventoryItem returning FALSE even though adding line

Postby aegean66 » Mon Apr 26, 2021 12:10 pm

Thanks Scott, much appreciated

Wasn't expecting a reply any time soon being JIWA 6 :)
aegean66
Occasional Contributor
Occasional Contributor
 
Posts: 36
Joined: Wed Mar 02, 2011 2:26 pm
Topics Solved: 2

Re: AddInventoryItem returning FALSE even though adding line

Postby aegean66 » Mon Apr 26, 2021 5:03 pm

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
aegean66
Occasional Contributor
Occasional Contributor
 
Posts: 36
Joined: Wed Mar 02, 2011 2:26 pm
Topics Solved: 2

Re: AddInventoryItem returning FALSE even though adding line

Postby Scott.Pearce » Mon Apr 26, 2021 5:05 pm

Is this in VBScript?
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: AddInventoryItem returning FALSE even though adding line

Postby aegean66 » Mon Apr 26, 2021 5:19 pm

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
aegean66
Occasional Contributor
Occasional Contributor
 
Posts: 36
Joined: Wed Mar 02, 2011 2:26 pm
Topics Solved: 2


Return to Technical / Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron