Hi Jeff,
There is an event the sales order entry form fires whenever a line is displayed, hook into that and then lock the columns associated with custom fields.
1. In the setup of the form plugin class, add a handler for the LineDisplayed event of the sales order form:
- Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
_SalesOrderForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)JiwaForm;
_SalesOrderForm.LineDisplayed += SalesOrderForm_LineDisplayed;
}
2. In the LineDisplayed handler, find the row in the grid, and then for each column in the grid for that row that is a custom line field column, lock the column.
- Code: Select all
private void SalesOrderForm_LineDisplayed(object sender, System.EventArgs e, JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine SalesOrderLine)
{
// lock all the custom fields if it is a comment
if (SalesOrderLine.CommentLine)
{
LockCommentLineCustomFields(SalesOrderLine);
}
}
private void LockCommentLineCustomFields(JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine SalesOrderLine)
{
// find the row in the grid the sales order line occupies
for(int row = 0; row < _SalesOrderForm.grdLines.ActiveSheet.RowCount; row++)
{
if (_SalesOrderForm.grdLines.get_GridText("Key", row).ToString() == SalesOrderLine.RecID)
{
// Iterate through each custom field and lock the associated grid column.
foreach(JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomField customLineField in SalesOrderLine.SalesOrderLines.SalesOrder.LineCustomFields)
{
_SalesOrderForm.grdLines.LockColumn(true, customLineField.PluginCustomField.GridColumnName, row);
}
break;
}
}
}
Sample incorporating the above is attached.
Mike