Page 1 of 1

Sales Order Custom Line Fields

PostPosted: Fri Sep 04, 2015 11:32 am
by Professional
Hi,

I have created a plugin to have a set of custom fields for sales order line entry. What do I need to do to restrict them as entry fields on comment lines?

Thanks,
Jeff

Re: Sales Order Custom Line Fields  Topic is solved

PostPosted: Fri Sep 04, 2015 4:22 pm
by Mike.Sheen
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.
Plugin Sales Order Lock Custom Line Fields for Comments.xml
Sample plugin
(33.99 KiB) Downloaded 462 times


Mike