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

Discussions relating to plugin development, and the Jiwa API.

Set initiated date of SO to now()

Postby DamonR » Thu Aug 08, 2024 4:23 pm

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.
DamonR
I'm new here
I'm new here
 
Posts: 2
Joined: Mon Jul 15, 2024 4:08 pm

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

Postby Mike.Sheen » Thu Aug 08, 2024 5:43 pm

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.
Attachments
Plugin Set SO Initiated Date On Order Type change.xml
(4.59 KiB) Downloaded 67 times
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: 2488
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 770

Re: Set initiated date of SO to now()

Postby DamonR » Fri Aug 09, 2024 9:55 am

Brilliant, thanks Mike. Above and beyond.
DamonR
I'm new here
I'm new here
 
Posts: 2
Joined: Mon Jul 15, 2024 4:08 pm


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests

cron