Calling methods on a caller form

Due to the poor design on some form I have to make changes to, I needed this thing here. I replaced a button on the form with code behind it (yes, business logic behind a button is a BAD practice !) by a MenuItemButton. The only problem was that the form had some objects (f.e. a ledgerJournalEngine object, …) that needed to be available in the class behind it…
Now, this is what I did to get the ledgerJournalEngine object from the caller form and pass it to the class I was calling :
// Get the caller form CIMVendTransInvoicePool to get the ledgerjournalengine object
if(ClassIdGet(_args.caller()) == ClassNum(SysSetupFormrun) && ( == formStr(CIMVendTransInvoicePool)))
      if (formHasMethod(_args.caller(), identifierStr(parmLedgerJournalEngine)))
         ledgerJournalEngine = _args.caller().parmLedgerJournalEngine();

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.