Page 1 of 1

Intercepting sales order XML Import

PostPosted: Wed Aug 12, 2026 4:16 pm
by DannyC
This is the XML code block from the standard File Watcher plugin that imports sales orders.
Code: Select all
   Private Sub XMLFileImport(ByVal FileName As String)
        ' Import the file using the import queue manager
      SyncLock JiwaFinancials.Jiwa.JiwaApplication.Manager.CriticalSectionFlag         
           Dim importQueueManager As JiwaImportQManager.ImportQueueItemCollection = _plugin.Manager.BusinessLogicFactory.CreateBusinessLogic(Of JiwaImportQManager.ImportQueueItemCollection)(Nothing)
          
         Dim queueItem As JiwaImportQManager.ImportQueueItem = _plugin.Manager.CollectionItemFactory.CreateCollectionItem(Of JiwaImportQManager.ImportQueueItem)
         queueItem.TransformedXML = File.ReadAllText(FileName)
         queueItem.Status = JiwaImportQManager.ImportQueueItem.ImportQueueItemStatuses.ReadyForImport
         importQueueManager.Add(queueItem)
         queueItem.Process()
         If queueItem.Status = JiwaImportQManager.ImportQueueItem.ImportQueueItemStatuses.Failed Then
            Throw New System.Exception(queueItem.ImportErrorMessage)
         Else
            XMLWatcher.LogToEventLog(String.Format("Imported XML from File '{0}'", FileName), System.Diagnostics.EventLogEntryType.SuccessAudit)            
         End If
      End SyncLock
   End Sub


Is it possible to intercept the XML before its written to Jiwa so we can adjust the sales order before it lands?

For example, lets say the debtor is 1002-Arthur Creams and we want to do something like add a comment line, maybe change the warehouse it lands in, add a special freight charge, or any other myriad of things that might be possible?

I've done it plenty of times using the CSV file watcher but funnily enough never the XML import.

Re: Intercepting sales order XML Import

PostPosted: Thu Aug 13, 2026 6:39 am
by SBarnes
There is a DeserialiseStart event which takes a JiwaFinancials.Jiwa.JiwaSales.SalesOrder.XML.SalesOrder as an object and has the signature below where sender is the sales order and poco is the JiwaFinancials.Jiwa.JiwaSales.SalesOrder.XML.SalesOrder, there is also DeserialiseEnd which is once Jiwa has deserialised the XML

Code: Select all
public delegate void DeserialiseStartEventHandler(object sender, EventArgs e, object poco);

Re: Intercepting sales order XML Import

PostPosted: Thu Aug 13, 2026 2:42 pm
by Mike.Sheen
As Stuart said - use the DeserialiseStart event to modify the poco before the sales order business logic deserialises it.

A potential problem will be adding that handler so it only alters the deserialising when coming from the filewatcher - it may not be an issue - you may be ok with all XML imports of sales orders behaving the same - but if you do want to make that distinction, then I wouldn't use the DeserialiseStart event of the sales order business logic and instead handle the Import Queue Manager ProcessItemStart event and meddle with the XML there.

The standard Jiwa file watcher uses the Import Q Manager for both the normal XML imports (C:\ProgramData\Jiwa Financials\Jiwa 7\Import\XML folder) and the XML queue imports (C:\ProgramData\Jiwa Financials\Jiwa 7\Import\XML Queue folder), as the Import Q Manager knows how to route our different XML documents to the right business logic (by looking at the Type attribute of the JiwaDocument node).

The attached plugin demonstrates how to do this - it just adds a "WEB:" prefix to the reference for sales order XML imported via the Import Q Manager.