Page 1 of 1

Custom float field in Quote Lines does not permit decimals  Topic is solved

PostPosted: Thu Nov 29, 2018 9:18 am
by Atronics
I have installed some custom fields into Quote Lines as type = Float. However, they do not allow a decimal input. How do I set the decimal places of these fields?

Re: Custom float field in Quote Lines does not permit decima

PostPosted: Thu Nov 29, 2018 10:47 am
by Mike.Sheen
There's a couple of ways to do it, but for quotes and sales orders the method which is in my opinion the easiest and most flexible is to add a handler for the LineCustomSettingValuesDisplayed event of the form and format the cells in there.

This means your plugin will need to add to the Forms tab the quote entry form. You'll also need the following code:

Code: Select all
public class FormPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaFormPlugin
{
   public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      JiwaFinancials.Jiwa.JiwaSalesUI.SalesQuote.SalesQuoteEntryForm quoteForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesQuote.SalesQuoteEntryForm)JiwaForm;
      quoteForm.LineCustomSettingValuesDisplayed += delegate(JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomField customField, int Row, ref JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid GridObject) { QuoteForm_LineCustomSettingValuesDisplayed(customField, Row, GridObject, quoteForm, Plugin); };                  
    }
   
   private void QuoteForm_LineCustomSettingValuesDisplayed(JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomField customField, int Row, JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid GridObject, JiwaFinancials.Jiwa.JiwaSalesUI.SalesQuote.SalesQuoteEntryForm quoteForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin plugin)
   {
      JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuoteLine salesQuoteLine = quoteForm.SalesQuote.SalesQuoteLines[GridObject.get_GridText("Key", Row).ToString()];
      
      quoteForm.grdLines.GridDecimalPlaces(String.Format("{0}.{1}", plugin.Name, "Field1"), Row, salesQuoteLine.QuantityDecimalPlaces);
      quoteForm.grdLines.GridDecimalPlaces(String.Format("{0}.{1}", plugin.Name, "Field2"), Row, quoteForm.SalesQuote.SystemSettings.MoneyDecimalPlaces);
      quoteForm.grdLines.GridDecimalPlaces(String.Format("{0}.{1}", plugin.Name, "Field3"), Row, 2);      
   }
}


A sample plugin is attached.

Re: Custom float field in Quote Lines does not permit decima

PostPosted: Thu Nov 29, 2018 11:15 am
by Atronics
A perfect and elegant solution.

Thanks