Page 1 of 1

Accessing Lines on a Sales Order

PostPosted: Fri Aug 21, 2015 11:01 am
by aegean66
Hi there,

I've looked on this forum and cannot find an answer.

I just want to be able to loop through the lines of a sales order, and action depending on values on any line

I'm no vba expert, but I have worked out how to say show a msgbox when conditions are met for a sales order, but not for the lines on a sales order.

Can someone help me out with the syntax for that?

Many thanks,
Damon.

Re: Accessing Lines on a Sales Order

PostPosted: Fri Aug 21, 2015 12:00 pm
by Scott.Pearce
You could use a For loop:

https://msdn.microsoft.com/en-us/library/5z06z1kb.aspx

or you could use a For Each loop:

https://msdn.microsoft.com/en-us/library/5ebk1751.aspx

For our sales order object specifically you could use something like:

Code: Select all
For Each existingSalesOrderLine As JiwaSales.SalesOrder.SalesOrderLine In mySalesOrderObject
   If existingSalesOrderLine.PartNo = "Fred" Then
      Msgbox("Sales order line no. " + existingSalesOrderLine.ItemNo + " has a part no. of '" + existingSalesOrderLine.PartNo + "'.")
   End If
Next

Re: Accessing Lines on a Sales Order

PostPosted: Fri Aug 21, 2015 1:20 pm
by aegean66
Thanks for the reply.

I'm just experimenting with the Form Loaded event with this code, and I get the following error?

Image

Re: Accessing Lines on a Sales Order

PostPosted: Fri Aug 21, 2015 1:39 pm
by Mike.Sheen
aegean66 wrote:Thanks for the reply.

I'm just experimenting with the Form Loaded event with this code, and I get the following error?

Image


Your image:
Image

For some reason does not display, but when I go to the dropbox it is linked to I see the image:
screenshot.jpg


Now that we can see the image, it is apparent you are using version 6 of Jiwa, not version 7. The guidance Scott gave you was for version 7 as that is where you posted this thread.

I'm moving this thread to the version 6 forums, where it will be dealt with there.

Mike

Re: Accessing Lines on a Sales Order

PostPosted: Tue Aug 25, 2015 9:44 am
by aegean66
So how can I expose the lines on a sales order in JIWA 6, so that I can, for example, send a msgbox to the screen if certain values appear on a line.

cheers,
Damon

Re: Accessing Lines on a Sales Order

PostPosted: Tue Aug 25, 2015 10:01 am
by Scott.Pearce
Off the top of my head the lines can be accessed through SalesOrderObject.SalesOrderLines. Do note, however, that the collection may not be initialised until after the form loaded breakout is fired.

There is also some developer documentation at "C:\Program Files\Jiwa Financials\Jiwa\Help\Developer Documentation\Jiwa Sales Orders.chm" which you might find helpful.

Re: Accessing Lines on a Sales Order

PostPosted: Thu Sep 10, 2015 8:45 pm
by aegean66
Just in case anyone is wondering. This is how to go through each line on a sales order and test something.

For Each SalesOrderLineObject In SalesOrderObject.SalesOrderLines
If SalesOrderLineObject.ItemPrice < SalesOrderObject.Lcost Then
Msgbox ("Sell price is less than cost")
Else
End If
Next