Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Method disable/ Enable menuItembutton

2,442 views
Skip to first unread message

Trieu nguyen

unread,
Feb 14, 2010, 9:31:01 PM2/14/10
to
Hi All,

I am a newbie in ax programmer. I want to find exactly the method will
disable/enable menuiem or another control in ax for example : when I click
purchase order with status Invoice, I can not select Posting ->Invoice or
Packing slip, and when I click purchase order with status purchase order I
can select Posting ->invoice, packing slip.. How can I find exactly method in
system will use for disable/enable menuitembutton or another controls ?

Thanks and best regard

Trieu nguyen

sams

unread,
Feb 14, 2010, 10:26:01 PM2/14/10
to
Hi Trieu,
Have a look at Forms\LedgerJournalTransVendPaym\enableButtonsActive
and http://msdn.microsoft.com/en-us/library/aa882795.aspx.
Hope this helps.

Trieu nguyen

unread,
Feb 14, 2010, 10:43:01 PM2/14/10
to
Hi Sams,

Thanks you so much for your reply. I am very confuse with your answer. I
aleady click in PurchTable form and I click in purchase order after that I
click in Posint-> Invoice or Packing slip.. I want to find exactly the
system method will use for disable/enable menuitem in this form ? I already
find method (Click) of menuitem group but I do not see the method will
disable/enable the menuitembutton .

Thanks and best regard

Trieu nguyen

Luegisdorf

unread,
Feb 15, 2010, 4:24:01 AM2/15/10
to
Hi Trieu

I assume the 'enabled(true/false)' property on the menuItemButton Object is
used for that ... if this was your question (which I don't be sure about ..).

Regards
Patrick

Klaas Deforche

unread,
Feb 15, 2010, 8:21:01 AM2/15/10
to
Hi Trieu,

More detailed steps if you're having trouble:

Step 1:
Go to your button in the AOT, and set the Autodeclaration property of the
button to Yes. This will make sure you can modify the properties of this
button from code.

Step 2:
Go to the form datasource and overwrite the method 'active'.
In this method you can enable/disable the button depending on values of the
selected record, eg:
if(purchTable.purchStatus == PurchStatus::invoiced)
{
yourbutton.enabled(true);
}
else
{
yourbutton.enabled(false);
}

- yourbutton == the name of the button control you set the autodeclaration
property to yes of.
- enabled() == the method that lets you enable and disable controls on a form.

Hope this helps,
Best regards,
Klaas.
----------------
http://www.artofcreation.be

Trieu nguyen

unread,
Feb 15, 2010, 8:41:01 PM2/15/10
to
Hi Luegisdorf,

Thanks you so much for your reply. I want to find exactly the system method
will use disable/enable menuitembutton(Posting) in PurchTable form.

Thanks and best regard

Trieu nguyen

Trieu nguyen

unread,
Feb 15, 2010, 8:48:01 PM2/15/10
to
Hi Klaas,

Thanks you so much for your reply. I find in active method but I do not see
ButtonHeaderUpdateNow(Posting) in here and I want to find exactly the method
will disable/enable menuitembutton (Purchase order,Invoice,Packing slip etc).
I find in document I see I must override
PurchTableType.CanInvoiceBeUpdated().. for enable/disable for menuitembutton
invoice .. but I can not find method in purchTable will call this method ?

Thanks and best regard

Trieu nguyen

Klaas Deforche

unread,
Feb 16, 2010, 3:45:01 AM2/16/10
to
Hi Trieu,

Oh, in this case, I believe the method you're looking for is in the class
PurchTableForm, method enableUpdateJournalButtons().

It says:
/// <summary>
/// Sets the enabled property on buttons used for posting purchase orders.
/// </summary>

This method is called when you click the posting button on the form:
\Forms\PurchTable\Designs\Design\[Group:Table]\[ButtonGroup:ButtonHeader]\[MenuButton:ButtonHeaderUpdateNow]\Methods\clicked


The values (enable or disable) come from the method purchtable.checkIfUpdate
(it returns a container).
This in turn call the method PurchTableType.checkIfUpdate(), which calls the
method purchTableType.canInvoiceBeUpdated().

Hope this helps.

Best regards,
Klaas.
----------------
http://www.artofcreation.be

Trieu nguyen

unread,
Feb 16, 2010, 7:13:02 PM2/16/10
to
Hi Klaas,

Thanks you so much for your reply. It is exactly but when i debug this
method the system do not run when I click the button posting(My machine
already installl the Microsoft dynamics ax 2009 debugger and I can debug some
method) so i am not sure when i click button posting the first method system
use is enableUpdateButtonJournal().

sams

unread,
Feb 17, 2010, 1:50:04 AM2/17/10
to
Hi Trieu,
If I understand it correcly you need to use the "breakpoint" keyword.
Have a look here but be mindful of this: "Please note that using breakpoint
has a serious side effect:The breakpoint will be hit by all user sessions!
This is definitely something you don't want to do in a live environment."
http://blogs.msdn.com/emeadaxsupport/archive/2009/07/13/tips-tricks-around-debugging-x-code-in-dynamics-ax.aspx.

Trieu nguyen

unread,
Feb 17, 2010, 3:23:01 AM2/17/10
to
Hi Sams,

Thanks you so much for your reply. It is great for me. I will check it . I
thinks it will helpfull for me.

Thanks and best regard

Karin

unread,
Oct 7, 2011, 6:34:35 AM10/7/11
to
Hei,
sorry for bad English :(
In payroll calculation worksheet is field "sessionId" (if someone has opened a worksheet then this field > 0, else =0). Hw to get the button to be disabled as soon as this field is> 0?

________________________
void checkBlocked()
{
xSession session;
;
if (pclCalcJourTable.SessionId && pclCalcJourTable.RecId)


{

session = new xSession(pclCalcJourTable.SessionId, true);

if (!session || !session.userId())
{
pclCalcJourTable.SessionId = 0;
pclCalcJourTable.SessionLoginDateTime = utcDateTimeNull();
pclCalcJourTable.doUpdate();
}

btnJournalLines.enabled(false);
}
}

> On Sunday, February 14, 2010 9:31 PM Trieu nguyen wrote:

> Hi All,
>
> I am a newbie in ax programmer. I want to find exactly the method will
> disable/enable menuiem or another control in ax for example : when I click
> purchase order with status Invoice, I can not select Posting ->Invoice or
> Packing slip, and when I click purchase order with status purchase order I
> can select Posting ->invoice, packing slip.. How can I find exactly method in
> system will use for disable/enable menuitembutton or another controls ?
>
> Thanks and best regard
>
> Trieu nguyen


>> On Sunday, February 14, 2010 10:26 PM sams wrote:

>> Hi Trieu,
>> Have a look at Forms\LedgerJournalTransVendPaym\enableButtonsActive
>> and http://msdn.microsoft.com/en-us/library/aa882795.aspx.
>> Hope this helps.
>>
>> "Trieu nguyen" wrote:


>>> On Sunday, February 14, 2010 10:43 PM Trieu nguyen wrote:

>>> Hi Sams,
>>>
>>> Thanks you so much for your reply. I am very confuse with your answer. I
>>> aleady click in PurchTable form and I click in purchase order after that I
>>> click in Posint-> Invoice or Packing slip.. I want to find exactly the
>>> system method will use for disable/enable menuitem in this form ? I already
>>> find method (Click) of menuitem group but I do not see the method will
>>> disable/enable the menuitembutton .
>>>
>>> Thanks and best regard
>>>
>>> Trieu nguyen
>>>
>>> "sams" wrote:


>>>> On Monday, February 15, 2010 4:24 AM Luegisdorf wrote:

>>>> Hi Trieu
>>>>
>>>> I assume the 'enabled(true/false)' property on the menuItemButton Object is
>>>> used for that ... if this was your question (which I do not be sure about ..).
>>>>
>>>> Regards
>>>> Patrick
>>>>
>>>> "Trieu nguyen" wrote:


>>>>> On Monday, February 15, 2010 8:21 AM Klaas Deforche wrote:

>>>>> Hi Trieu,
>>>>>
>>>>> More detailed steps if you are having trouble:
>>>>>
>>>>> Step 1:
>>>>> Go to your button in the AOT, and set the Autodeclaration property of the
>>>>> button to Yes. This will make sure you can modify the properties of this
>>>>> button from code.
>>>>>
>>>>> Step 2:
>>>>> Go to the form datasource and overwrite the method 'active'.
>>>>> In this method you can enable/disable the button depending on values of the
>>>>> selected record, eg:
>>>>> if(purchTable.purchStatus == PurchStatus::invoiced)
>>>>> {
>>>>> yourbutton.enabled(true);
>>>>> }
>>>>> else
>>>>> {
>>>>> yourbutton.enabled(false);
>>>>> }
>>>>>
>>>>> - yourbutton == the name of the button control you set the autodeclaration
>>>>> property to yes of.
>>>>> - enabled() == the method that lets you enable and disable controls on a form.
>>>>>
>>>>> Hope this helps,
>>>>> Best regards,
>>>>> Klaas.
>>>>> ----------------
>>>>> http://www.artofcreation.be
>>>>>
>>>>>
>>>>> "Luegisdorf" wrote:


>>>>>> On Monday, February 15, 2010 8:41 PM Trieu nguyen wrote:

>>>>>> Hi Luegisdorf,
>>>>>>
>>>>>> Thanks you so much for your reply. I want to find exactly the system method
>>>>>> will use disable/enable menuitembutton(Posting) in PurchTable form.
>>>>>>
>>>>>> Thanks and best regard
>>>>>>
>>>>>> Trieu nguyen
>>>>>>
>>>>>> "Luegisdorf" wrote:


>>>>>>> On Monday, February 15, 2010 8:48 PM Trieu nguyen wrote:

>>>>>>> Hi Klaas,
>>>>>>>
>>>>>>> Thanks you so much for your reply. I find in active method but I do not see
>>>>>>> ButtonHeaderUpdateNow(Posting) in here and I want to find exactly the method
>>>>>>> will disable/enable menuitembutton (Purchase order,Invoice,Packing slip etc).
>>>>>>> I find in document I see I must override
>>>>>>> PurchTableType.CanInvoiceBeUpdated().. for enable/disable for menuitembutton
>>>>>>> invoice .. but I can not find method in purchTable will call this method ?
>>>>>>>
>>>>>>> Thanks and best regard
>>>>>>>
>>>>>>> Trieu nguyen
>>>>>>>
>>>>>>> "Klaas Deforche" wrote:


>>>>>>>> On Tuesday, February 16, 2010 3:45 AM Klaas Deforche wrote:

>>>>>>>> Hi Trieu,
>>>>>>>>
>>>>>>>> Oh, in this case, I believe the method you are looking for is in the class
>>>>>>>> PurchTableForm, method enableUpdateJournalButtons().
>>>>>>>>
>>>>>>>> It says:
>>>>>>>> /// <summary>
>>>>>>>> /// Sets the enabled property on buttons used for posting purchase orders.
>>>>>>>> /// </summary>
>>>>>>>>
>>>>>>>> This method is called when you click the posting button on the form:
>>>>>>>> \Forms\PurchTable\Designs\Design\[Group:Table]\[ButtonGroup:ButtonHeader]\[MenuButton:ButtonHeaderUpdateNow]\Methods\clicked
>>>>>>>>
>>>>>>>>
>>>>>>>> The values (enable or disable) come from the method purchtable.checkIfUpdate
>>>>>>>> (it returns a container).
>>>>>>>> This in turn call the method PurchTableType.checkIfUpdate(), which calls the
>>>>>>>> method purchTableType.canInvoiceBeUpdated().
>>>>>>>>
>>>>>>>> Hope this helps.
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>> Klaas.
>>>>>>>> ----------------
>>>>>>>> http://www.artofcreation.be
>>>>>>>>
>>>>>>>>
>>>>>>>> "Trieu nguyen" wrote:


>>>>>>>>> On Tuesday, February 16, 2010 7:13 PM Trieu nguyen wrote:

>>>>>>>>> Hi Klaas,
>>>>>>>>>
>>>>>>>>> Thanks you so much for your reply. It is exactly but when i debug this
>>>>>>>>> method the system do not run when I click the button posting(My machine
>>>>>>>>> already installl the Microsoft dynamics ax 2009 debugger and I can debug some
>>>>>>>>> method) so i am not sure when i click button posting the first method system
>>>>>>>>> use is enableUpdateButtonJournal().
>>>>>>>>>
>>>>>>>>> Thanks and best regard
>>>>>>>>>
>>>>>>>>> Trieu nguyen
>>>>>>>>>
>>>>>>>>> "Klaas Deforche" wrote:


>>>>>>>>>> On Wednesday, February 17, 2010 1:50 AM sams wrote:

>>>>>>>>>> Hi Trieu,
>>>>>>>>>> If I understand it correcly you need to use the "breakpoint" keyword.
>>>>>>>>>> Have a look here but be mindful of this: "Please note that using breakpoint
>>>>>>>>>> has a serious side effect:The breakpoint will be hit by all user sessions!
>>>>>>>>>> This is definitely something you do not want to do in a live environment."
>>>>>>>>>> http://blogs.msdn.com/emeadaxsupport/archive/2009/07/13/tips-tricks-around-debugging-x-code-in-dynamics-ax.aspx.
0 new messages