Page 1 of 1

Set initiated date of SO to now()

PostPosted: Thu Aug 08, 2024 4:23 pm
by DamonR
I'm sure this is really simple but I want to:

If: A user changes a sales order form a forward order to an invoice order (no other combination)

Then: Immediately change the initiated date of the sales order to now()

What is the event for the change of sales order type? I know about the "PostingDataType" setting in the main configuration, but none of these options suit us.

Re: Set initiated date of SO to now()  Topic is solved

PostPosted: Thu Aug 08, 2024 5:43 pm
by Mike.Sheen
The key point is to subscribe to the PropertyChanged event of the sales order and examine the Name of the property being changed - this is how you can react to changes of specific fields.

For example:

Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
   JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesOrder = (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)JiwaBusinessLogic;
   salesOrder.PropertyChanged += SalesOrder_PropertyChanged;
}

private void SalesOrder_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
   if (e.PropertyName == "OrderType")
   {
      JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesOrder = (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)sender;
      
      if (salesOrder.PreviousOrderType == JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder.SalesOrderOrderTypes.e_SalesOrderOrderTypeForwardOrder &&
         salesOrder.OrderType == JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder.SalesOrderOrderTypes.e_SalesOrderOrderTypeInvoiceOrder)
      {
         salesOrder.InitiatedDate = salesOrder.Manager.SysDateTime;
      }
   }
}


Plugin working with 7.2.1 SR20 attached.

Re: Set initiated date of SO to now()

PostPosted: Fri Aug 09, 2024 9:55 am
by DamonR
Brilliant, thanks Mike. Above and beyond.