Page 1 of 1

Sales Order Lines custom fields for kits

PostPosted: Fri Mar 04, 2016 4:42 pm
by DannyC
Hi,

version: 7.0.149
Lang: VB .Net

I am using a modified version of viewtopic.php?f=26&t=422 Sales Order Lines custom fields - make read only

This time I need to do basically the same except the difference will be that the custom field is read only for normal lines & kit component lines. In other words, editable for kit header lines only.
I am in a world of pain here - I thought this could be knocked over in an hour & have been struggling for about 6 hours!

I have attached the plugin here - almost identical to the plugin attached in the forum topic above except I am also checking for KitLineType.
No matter how I reprogram the plugin with various changes, I keep getting RowIndex errors similar to:
Error: Invalid Row Index: 3 (must be between 0 and 2)
Module: get_Item

The ultimate goal of the plugin is to make a kit backordered if any one component is on back order. I was going to use a custom line field to indicate the BO Qty of the kit header, then use that value to set the BO qty of all the kit components.

Cheers

Re: Sales Order Lines custom fields for kits  Topic is solved

PostPosted: Sat Mar 12, 2016 12:15 pm
by Mike.Sheen
Change
Code: Select all
For lineNumber As Integer = 0 To salesOrderForm.SalesOrder.SalesOrderLines.Count - 1

To
Code: Select all
For lineNumber As Integer = 0 To salesOrderForm.grdLines.ActiveSheet.RowCount - 1


You're getting an error on save as at the end of the save, a read is invoked and as part of that the LineDisplayed event you're handling is being invoked every time a line is added - so when the kit header is first added, the sales order lines collection has ALL the lines, but the grid only has one line - and you were trying to index rows which don't exist yet.

Re: Sales Order Lines custom fields for kits

PostPosted: Mon Mar 14, 2016 3:06 pm
by DannyC
That's awesome. No errors!