Copy Line Custom Field Data When Copying a Sales Order

Samples and Examples of using the Jiwa 7 framework - including plugins, stand-alone applications and scripts.

Copy Line Custom Field Data When Copying a Sales Order

Postby Scott.Pearce » Fri Oct 30, 2015 9:43 am

By default, sales order line custom field values are *not* brought across when copying a sales order (in fact, it looks like they are only shallow copied). This plugin changes the behaviour such that sales order line custom field values *do* come across to the copy, and are saved with the copy.

The plugin works by performing a deep copy on each lines' custom field value collection after a sales order copy has occurred. There is not much code to it, so I'll post it here in additional to the attached plugin XML:

Code: Select all
Public Class BusinessLogicPlugin
    Inherits System.MarshalByRefObject
    Implements JiwaApplication.IJiwaBusinessLogicPlugin

    Public Overrides Function InitializeLifetimeService() As Object
        ' returning null here will prevent the lease manager
        ' from deleting the Object.
        Return Nothing
    End Function

    Public Sub Setup(ByVal JiwaBusinessLogic As JiwaApplication.IJiwaBusinessLogic, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaBusinessLogicPlugin.Setup
      If TypeOf JiwaBusinessLogic Is JiwaSales.SalesOrder.SalesOrder Then
         Dim salesOrderObject As JiwaSales.SalesOrder.SalesOrder = DirectCast(JiwaBusinessLogic, JiwaSales.SalesOrder.SalesOrder)
         AddHandler salesOrderObject.CopyEnd, AddressOf salesOrderObject_CopyEnd
      End If
    End Sub
   
   Public Sub salesOrderObject_CopyEnd(sender As Object, e As System.EventArgs)
      Dim salesOrderObject As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
      
      For Each salesOrderLine As JiwaSales.SalesOrder.SalesOrderLine In salesOrderObject.SalesOrderLines
         salesOrderLine.CustomFieldValues.Copy
      Next
   End Sub

End Class
Attachments
Plugin Copy Line Custom Field Data When Copying a Sales Order.xml
(32.68 KiB) Downloaded 213 times
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Return to Samples and Examples

Who is online

Users browsing this forum: No registered users and 1 guest

cron