Page 1 of 1

Sales Order Line add before

PostPosted: Wed Nov 13, 2024 10:56 pm
by Riyaz
Hi There

Is it possible to check a certain condition when adding sales order line item is added by choosing a part no, and if that condition is not met, display a message box and not proceed with adding that line item?

Re: Sales Order Line add before  Topic is solved

PostPosted: Thu Nov 14, 2024 6:22 am
by SBarnes
The below in a form plugin is what you want, then do your check and if you need to show amessage to the user on error throw a JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException with your error message in the constructor, Jiwa will show the message and stop any further processing.

Also make sure you add the sales order form to the forms section of the plugin.

Code: Select all
public class FormPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaFormPlugin
{

    public override object InitializeLifetimeService()
    {
        // returning null here will prevent the lease manager
        // from deleting the Object.
        return null;
    }

    public void SetupBeforeHandlers(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
    }

    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      if (JiwaForm is JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)
      {
         //System.Diagnostics.Debugger.Launch();
         //System.Diagnostics.Debugger.Break();
         var salesOrderForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)JiwaForm;         
         salesOrderForm.SalesOrder.SalesOrderLineAdding += SalesOrderLines_Adding;
         
      }      
    }
   
   public void SalesOrderLines_Adding(object sender, System.EventArgs e, JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine Item)
   {
      
   }
}

Re: Sales Order Line add before

PostPosted: Thu Nov 14, 2024 11:32 pm
by Riyaz
Thanks Stuart