I cannot seem to figure out the simple mistake I'm committing with the
following code and wonder if someone out there can help me as I believe my
frustration is clouding my judgement.
I am trying to open the DocuView window and pass across a datasource of the
LedgerJournalTrans Table to display documents linked to those records. The
problem is I want to do this from the LedgerTransAccount form which has the
LedgerTrans table as it's datasource.
To reconcile the difference, I am performing a select statement against
LedgerJournalTrans where LedgerJournalTrans.Voucher = LedgerTrans.Voucher.
This in essence, gives me the LedgerJournalTrans record that I need to pass
over to DocuView to get the linked document.
I have added a button of MenuItemButton type, with a MenuItemName property
of 'DocuView'. I have also attached a clicked() method to the button that
executes the following code:
void clicked()
{
FormRun a_FormRun;
Args a_Args;
LedgerJournalTrans ljt;
;
SELECT FIRSTONLY ljt
WHERE ljt.Voucher == LedgerTrans.Voucher
&& ljt.AccountType == LedgerJournalACType::Vend;
if(ljt)
{
a_Args = new Args(ljt);
a_Args.name(formstr(DocuView));
a_FormRun = ClassFactory.formRunClass(a_Args);
a_FormRun.init();
a_FormRun.run();
a_FormRun.wait();
}
super();
}
When this code is executed through a button click, all I get is an error
that states "Object 'Args' could not be created."
I had this working, however our code deployer accidentally overwrote this
changes and I lost the functionality. I went back to a process I created
where I capture and write out all new changes to the AOT, but for some reason
now it does not work.
I know this is not the best practice way to open a form, however the unique
situation here is the datasource of the calling form is not the datasource I
want to pass across to be the basis for the new form.
Any ideas on may obviously simple problem would greatly be appreciated.
--
David Bowles
Developer/MCP
Shouldn't it be:
a_Args = new Args();
a_args.record(ljt);
in stead of
a_Args = new Args(ljt);
Kind regards,
Klaas
------------------
http://www.artofcreation.be
please try this.
a_Args = new Args();
a_Args.record(ljt);
a_Args.name(formstr(DocuView));
a_FormRun = ClassFactory.formRunClass(a_Args);
a_FormRun.init();
a_FormRun.run();
a_FormRun.wait();
Hope this hepls you.
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Insted of using formrun to open the docuView form
you can also call
DocuRef::openDocHandling(<record>, <callerform>)
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
I also tried your second suggestion and I don't have a static class method
called openDocHandling on my DocuRef class. I am on AX 4.0 RTM. We haven't
upgraded to 2009, yet.
I'll keep playing with it. I know it's something very simple I am missing
but I haven't ran across the problem, yet.
Thanks again,
--
David Bowles
Developer/MCP
i looked into this once again.
You are right. Calling to DocuView form with or over args and formrun
doesn't work.
But there is another (even simplier) way to open the docuview form for an
spezified record.
1. Add the MenuItem (Display) "DocuView" as MenuItemButton to your form.
No need to set the properties "DataSource" and so on for the MenuItemButton.
Yust place the MenuItem on your form.
2. Write a new Method "docCursor" on your Form which returns the record of a
datasource for which the docuview should be opened.
Example:
common docCursor()
{
;
//Must be a datasource on the form, doesn't work with a table buffer.
return custTable;
}
For you this means:
1. Add the LedgerJournalTrans as a Datasource to your Form.
2. Write a new method "docCursor" on your form which return the
LedgerJournalTrans record.
3. Place the MenuItem "DocuView" on your Form.
I have tested this in AX 4.0 and AX 2009. Works great.
Hope this helps you.