Sales Order Custom Line Fields  Topic is solved

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

Sales Order Custom Line Fields

Postby Professional » Fri Sep 04, 2015 11:32 am

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
Professional
Occasional Contributor
Occasional Contributor
 
Posts: 19
Joined: Mon Dec 08, 2008 3:45 pm

Re: Sales Order Custom Line Fields  Topic is solved

Postby Mike.Sheen » Fri Sep 04, 2015 4:22 pm

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 461 times


Mike
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


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests