Hi Danny,
Container fed by checkIfUpdate is actually built in method checkIfUpdate() in CLASS salesTableType, where it calls method can...BeUpdated() (and subsequently, method may...beUpdated()) to get enable status. Method checkIfUpdate() in salesTable simply calls method checkIfUpdate() in class SalesTableType. Try to set a breakpoint on this method, you'll get the idea.
Now I try to explain how you can enable the button for your new (additional) document. From this explanation you may grasp the mechanism applied in standard Axapta.
if you want to attach a new (additional) document update, there are things you have to prepare. Let's say you want to add another document called "pasca invoice" (whatever it is) to be posted, you'd probably follow these steps:
1. Add a new element PascaInvoice in base enum DocumentStatus
2. Duplicate menu item action SalesFormLetter_Invoice then change the properties:
Name : SalesFormLetter_PascaInvoice
Label: Pasca invoice
EnumParameter: pascaInvoice
3. In the design form SalesTable, add menuItemButton under MenuButton ButtonHeaderUpdate:
Name : buttonUpdatePascaInvoice
AutoDeclaration: Yes
MenuItemType: Action
MenuItemName: SalesFormLetter_PascaInvoice
DataSource: SalesTable
Up to this point, you might test it and find error when you click menu 'Pasca Invoice'.
It's because your new DocumentStatus::PascaInvoice has not been recognized by class
salesFormLetter. You must create a new class called SalesFormLetter_PascaInvoice which extends SalesFormLetter. The objective of this new class is to process your document. Inside the static method construct(...) of class SalesFormLetter, add a line of code for your new class instantiation inside the switch:
case DocumentStatus::PascaInvoice: return new SalesFormLetter_PascaInvoice (getParmId);
I don't discuss the implementation inside your new class, since it depends on your requirements and time consuming as well. There are also some related classes, tables, and other objects to consider. But you can try to figure out the process by examining similar classes such as SalesFormLetter_Invoice, SalesFormLetter_PackingSlip, etc. Don't forget also to look at the form SalesEditLine which is the intermediate form opened before the document is actually posted.
4. Now, modify class SalesTableType, add these new methods:
boolean mayPascaInvoiceBeUpdated()
{
// let's say, it may only be updated if the sales order status is invoiced
return (salesTable.salesStatus == SalesStatus::Invoiced);
}
boolean canPascaInvoiceBeUpdated()
{
boolean ok;
;
ok = this.mayPascaInvoiceBeUpdated();
if (ok)
{
// if it may be updated, what make it can't
// ... add your own validation here,
}
return ok;
}
client server static int posPascaInvoice()
{
return 8; // the highest index in standard is 7, so just make it 8
}
// modify checkIfUpdate. remember this method is a member of class SalesTableType
container checkIfUpdate()
{
container c;
.
.
.
// add this line
c = conIns(c, SalesTableType::posPascaInvoice(), this.canPascaInvoiceBeUpdated());
return c;
}
5. Modify class SalesTableForm
void enableUpdateJournalButtons(SalesTable _salesTable,
FormFunctionButtonControl buttonUpdateQuotation,
FormFunctionButtonControl buttonUpdateConfirmation,
FormFunctionButtonControl buttonUpdatePickingList,
FormFunctionButtonControl buttonUpdatePickingListRegistrate,
FormFunctionButtonControl buttonUpdatePackingSlip,
FormFunctionButtonControl buttonUpdateInvoice,
FormFunctionButtonControl buttonUpdateProjectPackingSlip,
// add this parameter
FormFunctionButtonControl buttonUpdatePascaInvoice
)
{
FormDataSource salesTable_ds;
SalesTable localSalesTable;
SalesTableType salesTableType;
container checkIfupdate;
.
.
// add this
boolean enablePascaInvoiceButton = buttonUpdatePascaInvoice? false : true;
;
salesTable_ds = _salesTable.dataSource();
localSalesTable = salesTable_ds.getFirst(true);
if (localSalesTable)
{
while(localSalesTable)
{
if ((enableQuotationButton == true) &&
(enableConfirmationButton == true) &&
(enablePickingListButton == true) &&
(enablePickingListRegistrateButton == true) &&
(enablePackingSlipButton == true) &&
(enableInvoiceButton == true) &&
(enableProjectPackingSlipButton == true) &&
(enablePascaInvoiceButton == true))
{
break;
}
.
.
.
if (!enablePascaInvoiceButton)
enablePascaInvoiceButton = salesTableType.mayPascaInvoiceBeUpdated();
localSalesTable = salesTable_ds.getNext();
}
}
else
{
// you might find that _salesTable.checkIfUpdate() will actually call method
// chekIfUpdate() in class salesTableType ...
// no wonder method may...BeUpdated() is called as well
checkIfupdate = _salesTable.checkIfUpdate();
.
.
enablePascaInvoiceButton = conPeek(checkIfUpdate,
SalesTableType::posPascaInvoice());
}
.
.
if (buttonUpdatePascaInvoice)
buttonUpdatePascaInvoice.enabled(enablePascaInvoiceButton);
}
By similar changes, apply this modification code to method enableUpdateJournalTransButtons()
6. Modify form SalesTable, in the clicked method of ButtonHeaderUpdate
void clicked()
{;
salesTableForm.enableUpdateJournalButtons(salesTable,
buttonUpdateQuotation,
buttonUpdateConfirmation,
buttonUpdatePickingList,
buttonUpdatePickingListRegistrate,
buttonUpdatePackingSlip,
buttonUpdateInvoice,
null,
// add this line
buttonUpdatePascaInvoice
);
super();
}
While some modifications applied to classes, you also have to consider changes applied to their subclasses, otherwise you will experience run time errors in some cases. Using add-ins 'Compile forward' will be a good practice to update the subclasses.
Good code, good luck.
Happy coding.
-Aji Sarosa-
[EMAIL PROTECTED]
Programmer
Jakarta, Indonesia
Danny Gaethofs <[EMAIL PROTECTED]> wrote:
Thanks a lot Aji,
Before I saw your answer I spent a lot of time on
figuring all of this out. You confirm what I learned
meanwhile.
Nevertheless the thing I still do not catch is where
the container checkIfupdate gets its values. During my
analysis I did find the method checkIfUpdate() on the
SalesTable but I do not understand how the container
is build.
The main reasons why I am asking this is because I
want to add an extra document to it.
I saw the whole stuff with the posQuotation method and
the mayQuotationBeUpdated method.
I noticed that when the method
enableUpdateJournalButtons is run the else loop is
executed. Whereas normally the method
mayQuotationBeUpdated is called within the if loop I
noticed that the statement checkIfupdate =
_salesTable.checkIfUpdate() calls the
mayQuotationBeUpdated also.
That is where I am lost! How can this method build the
container and how can it call the
mayQuotationBeUpdated method.
I would appreciate it if you could tell me how it is
done.
I have temporarily solved it by assigning the enable
value for my new document hardcoded, setting it to
true. But this is not the longterm solution.
regards,
Danny
-- DELETED
---------------------------------
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
[Non-text portions of this message have been removed]
| Yahoo! Groups Sponsor |
| Get unlimited calls to U.S./Canada |
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/development-axapta/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

