Page 1 of 1

Programmatically opening Stock Transfer in editable mode

PostPosted: Mon Sep 15, 2025 4:47 pm
by DamonR
Hi guys,

I've been frustratingly trying to prgrammatically open a new stock transer tab in a Jiwa 7.2.1 VB.NET plugin.

From Sales Order form, I add a ribbon button and try to open a new Stock Transfer tab. The ST UI opens but is non-interactive and shows the red “Activated” badge.

Diagnostic shows:
Form type: JiwaFinancials.Jiwa.JiwaStockTransferUI.MainForm (assembly JiwaStockTransferUI.dll)
Public zero-param method: NewRecord()
Ribbon tool exists: key ID_RecordNew (“New”)

Calling NewRecord() and/or clicking ID_RecordNew via reflection doesn’t change the state.
Direct instantiation via Activator.CreateInstance + Show() behaves the same.
Forcing flags (ReadOnly/Activated/Locked) and setting Status=1 (Open) on the form/guessed BO has no effect.
The MDI parent doesn’t expose a usable “New” tool for this form.

What is the supported API to open the Stock Transfer UI in New (editable) mode from another form/plugin?
Is there an application/forms manager I should call (e.g. JiwaApplication.FormsManager/OpenForm/CreateForm) rather than Activator.CreateInstance?
If so, what method name/signature should we use and what string/type identifier should we pass for Stock Transfer?
Does MainForm require a business object to be created/bound before calling NewRecord()?
If yes, what is the correct BO type and factory to use, and how do I attach it to MainForm (method/property name)?
After binding, is MainForm.NewRecord() the correct entry point, or is there another public method (e.g. RecordNew, CreateNew) I should call?
The badge shows Activated; our DB mapping is 0 = Activated, 1 = Open.
Which property/enum on the form/BO does the UI bind to for this status?
Where can I access that object from MainForm (property name), and is there a supported way to set it to Open programmatically?
Are there any security/permission checks or initialisation steps (e.g., session/context services) that prevent programmatic “New” unless opened via the official manager?

Could you provide a minimal VB.NET snippet (Jiwa 7.2.1-compatible) that opens JiwaStockTransferUI.MainForm as an MDI child from another form and ensures it’s in New state and editable?

Thanks in advance.

Re: Programmatically opening Stock Transfer in editable mode  Topic is solved

PostPosted: Mon Sep 15, 2025 5:34 pm
by Mike.Sheen
The recommended way to create an instance of a form is to use the FormFactory.

Attached is a plugin (in VB.NET, for Jiwa 7.2.1) which adds a tool to the sales order ribbon, and when pressed it opens a stock transfer form, creates a new transfer and adds all the lines on the sales order which have backorders and sets the transfer quantity to be the backorder quantity.
Plugin Open Stock Transfer Form.xml
(13.58 KiB) Downloaded 481 times


The significant portion is:
Code: Select all
Dim stockTransferForm As JiwaFinancials.Jiwa.JiwaStockTransferUI.MainForm = salesOrderForm.Manager.FormFactory.CreateForm(Of JiwaFinancials.Jiwa.JiwaStockTransferUI.MainForm)()
' Set stockTransferForm.DrillDownID before calling Start() if you want to load an existing transfer, Or you can call stockTransferForm.StockTransfer.Read(RecID) after Start()   
stockTransferForm.Start()         
stockTransferForm.StockTransfer.CreateNew()   

Re: Programmatically opening Stock Transfer in editable mode

PostPosted: Mon Sep 15, 2025 5:46 pm
by SBarnes
Although in c# the attached plugin should give you enough to go by, basically you need to use the manager on the sales form to create the form using is form factory and then start the form to get it to dock as a tab and then call new record.

Re: Programmatically opening Stock Transfer in editable mode

PostPosted: Mon Sep 15, 2025 5:47 pm
by DamonR
Wont be forgetting that in a hurry. Thanks Mike!