Sales Order Line add before  Topic is solved

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

Sales Order Line add before

Postby Riyaz » Wed Nov 13, 2024 10:56 pm

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?
Riyaz
Kohai
Kohai
 
Posts: 254
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: Sales Order Line add before  Topic is solved

Postby SBarnes » Thu Nov 14, 2024 6:22 am

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)
   {
      
   }
}
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Sales Order Line add before

Postby Riyaz » Thu Nov 14, 2024 11:32 pm

Thanks Stuart
Riyaz
Kohai
Kohai
 
Posts: 254
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 6 guests