Accessing sales order lines by line number ( index )  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Accessing sales order lines by line number ( index )

Postby indikad » Mon Aug 10, 2015 3:53 pm

I need to loop through OR access the sales order lines using the incremental number ( NOT in a For Each loop )
however my syntax gives me an error "Overload resolution failed because no accessible "Item" can be called without a narrowing conversion"
on compilaiton - see my code below. The issue is on the msgbox line
appreciate if someone can help.

Code: Select all
Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      If TypeOf JiwaForm Is JiwaSalesUI.SalesOrder.SalesOrderEntryForm  Then         
           Dim SalesOrdForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(JiwaForm, JiwaApplication.IJiwaForm)         
'         AddHandler  SalesOrdForm.SalesOrder.Created , AddressOf SalesOrderCreated   
         AddHandler SalesOrdForm.SalesOrder.CreateEnd , AddressOf SalesOrderCreateEnd
       End If
    End Sub
   Public Sub SalesOrderCreateEnd(ByVal sender As Object ,ByVal  e As  System.EventArgs )
      Dim oSalesOrder As JiwaSales.SalesOrder.SalesOrder   = DirectCast( sender , JiwaSales.SalesOrder.SalesOrder )
      Dim lOrdLine As Long       
      For lOrdLine = 1 To oSalesOrder.SalesOrderLines.Count 
         msgbox(   oSalesOrder.SalesOrderLines.Item(lOrdLine).PartNo.ToString())         
      Next
      
   End Sub
Last edited by indikad on Thu Aug 13, 2015 5:38 pm, edited 1 time in total.
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Traversing sales order lines by line number

Postby DannyC » Tue Aug 11, 2015 8:36 am

Indika,
This might help

Code: Select all
      
For Each lOrdLine As JiwaSales.SalesOrder.SalesOrderLine In oSalesOrder.SalesOrderLines
      Msgboxl(lOrdLine.PartNo & "    " & lOrdLine.ItemNo )
Next


You may be able to help me with some outstanding questions...!
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Traversing sales order lines by line number

Postby indikad » Tue Aug 11, 2015 12:53 pm

Hi Danny - thanks for the attention.

I am aware of the For each way of looping.
as per my original post - I need a another way WITHOUT the use of "For Each"

also at times I need to access the line item and edit it using something like
Code: Select all
_oCurrentSalesOrder.SalesOrderLines("Linendex").QuantityOrdered = 500  ' this code does not work
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Accessing sales order lines by line number ( index )  Topic is solved

Postby Mike.Sheen » Tue Aug 18, 2015 4:38 pm

indikad wrote:I need to loop through OR access the sales order lines using the incremental number ( NOT in a For Each loop )
however my syntax gives me an error "Overload resolution failed because no accessible "Item" can be called without a narrowing conversion"
on compilaiton - see my code below. The issue is on the msgbox line
appreciate if someone can help.

Code: Select all
Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      If TypeOf JiwaForm Is JiwaSalesUI.SalesOrder.SalesOrderEntryForm  Then         
           Dim SalesOrdForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(JiwaForm, JiwaApplication.IJiwaForm)         
'         AddHandler  SalesOrdForm.SalesOrder.Created , AddressOf SalesOrderCreated   
         AddHandler SalesOrdForm.SalesOrder.CreateEnd , AddressOf SalesOrderCreateEnd
       End If
    End Sub
   Public Sub SalesOrderCreateEnd(ByVal sender As Object ,ByVal  e As  System.EventArgs )
      Dim oSalesOrder As JiwaSales.SalesOrder.SalesOrder   = DirectCast( sender , JiwaSales.SalesOrder.SalesOrder )
      Dim lOrdLine As Long       
      For lOrdLine = 1 To oSalesOrder.SalesOrderLines.Count 
         msgbox(   oSalesOrder.SalesOrderLines.Item(lOrdLine).PartNo.ToString())         
      Next
      
   End Sub


Instead of

Code: Select all
Dim lOrdLine As Long


Try

Code: Select all
Dim lOrdLine As Integer
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Accessing sales order lines by line number ( index )

Postby indikad » Tue Aug 18, 2015 5:01 pm

Thanks Mike. Will update soon.
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 5 guests

cron