Intercepting sales order XML Import

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

Intercepting sales order XML Import

Postby DannyC » Wed Aug 12, 2026 4:16 pm

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.
User avatar
DannyC
Senpai
Senpai
 
Posts: 745
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 32

Re: Intercepting sales order XML Import

Postby SBarnes » Thu Aug 13, 2026 6:39 am

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);
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1712
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 192

Re: Intercepting sales order XML Import

Postby Mike.Sheen » Thu Aug 13, 2026 2:42 pm

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.
Attachments
Plugin Import Queue Manager - Modify Sales Order.xml
(6.89 KiB) Downloaded 1397 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: 2625
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 824


Return to Technical and or Programming

Who is online

Users browsing this forum: SBarnes and 91 guests