Notifications
Announcements
No record found.
How to pass values from Form B to Form A. The scenario is I'm going to click Settle Transactions which opens a new form and it will show a list which I can mark. After mark item and click save, I want to pass the marked values to Form B.Form : LedgerJournalTransVendInvoiceControl Name : ButtonSettlementForm Name : VendOpenTransControl Name : SavePlanning to pass the value invoice to Form AIs it possible to use an event handler to control VendOpenTrans.Save then pass it to Form A? Thanks in advance
In init method of form B, you can access the caller form A (FormRun class instance) via element.args().caller().
Once you have the caller, you can access anything in form A, including controls, data sources and (public) methods.
And, of course in Form B you can send info back to Form A, because you have the pointer to it.
[FormControlEventHandler(formControlStr(VendOpenTrans, Save), FormControlEventType::Clicked)] public static void Save_OnClicked(FormControl sender, FormControlEventArgs e) { //Access Invoice column in VendOpenTrans and pass it to LedgerJournalTransVendInvoice }
How am I going to use the pointer in the event handler?
Use sender.formRun() to get FormRun of current form. Once you have that, call formRun.args().caller() to get the caller formRun.
FormRun _formRun = sender.formRun(); FormRun callerForm = _formRun.args().caller(); //Object reference not set to an instance of an object FormDataSource _ledgerJournalTransVendInvoice = callerForm.dataSource(formDataSourceStr(LedgerJournalTransVendInvoice, LedgerJournalTrans));
This should work normally, but of course only when form B is opened directly from form A, and caller is passed via args.
I don't have a system at hand, but please look what the button in the first form calls. Most likely by looking at the button (menu item, clicked method) you will understand what pieces are involved and how to adjust your code.
You can also put a breakpoint in the init method of form B, and check the call stack with debugger.
Please share all your findings with us.
I checked it a bit, and indeed in this case "caller" object is not provided to the settlement form.
The args are defined in Classes\LedgerJournalEngine\createArgsForSettlementForm.
To me it seems that the caller form is passed to LedgerJournalEngine class (via _formRun variable in constructor method).
So, you could try to use Chain of Command in the createArgsForSettlementForm, and put that formRun variable in args.caller(). However that could cause some unexpected behavior which you would find out in testing.
If there are issues, you could pass it via args.object() and handle it accordingly on form B.
Hello Nikolaos, below is my solution.You need to do create a form extension for VendOpenTrans and implement Chain of Command in init() and create a method that has a return value of LedgerJournalTrans,
[ExtensionOf(formStr(VendOpenTrans))] final class VendOpenTrans_Extension { public LedgerJournalTrans _LedgerJournalTrans; public void init() { next init(); switch (originator.TableId) { case tableNum(LedgerJournalTrans): _LedgerJournalTrans = this.args().record(); break; } } public LedgerJournalTrans getLedgerJournalTrans() { return _LedgerJournalTrans; } }
[FormControlEventHandler(formControlStr(VendOpenTrans, Save), FormControlEventType::Clicked)] public static void VendOpenTransSave_OnClicked(FormControl sender, FormControlEventArgs e) { FormRun _formRun = sender.formRun(); FormDataSource _vendTransDS = _formRun.dataSource(formDataSourceStr(VendOpenTrans, VendTrans)); VendTrans _vendTrans = _vendTransDS.cursor(); LedgerJournalTrans _ledgerJournalTrans; _ledgerJournalTrans = _formRun.getLedgerJournalTrans(); //Method that you created from VendOpenTrans extension //Pass the value from form B to form A _ledgerJournalTrans.Invoice = _vendTrans.Invoice; }
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 551 Most Valuable Professional
André Arnaud de Cal... 450 Super User 2025 Season 2
BillurSamdancioglu 278 Most Valuable Professional