Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

How to enable/disable delete button in the Attachment(Document Handling) based on Enum status

(0) ShareShare
ReportReport
Posted on by 2,172

Hello all,

In my customized transaction form, I want to disable delete button in the attachment(Document Handling) based on enum status in the transaction header of the form. How to achieve this?

*This post is locked for comments

  • Verified answer
    Maciej Obojski Profile Picture
    Maciej Obojski 610 on at
    RE: How to enable/disable delete button in the Attachment(Document Handling) based on Enum status

    Hi,

    please have a look inside DocuView form, doReSearch method, around line number 160 and below. Hopefully you will see that there is already some code there that sets variable called 'allowEditBasedOnActualForm'.

    In my installation there is even some code for Norway, which checks the calling table and sets the variable based on some fields - looks like exactly what you need ?

       if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoNO]) &&

          (testCursor.TableId == tablenum(CustInvoiceJour) || testCursor.TableId == tablenum(ProjInvoiceJour)))

       {

           switch (testCursor.TableId)

           {

               case tablenum(CustInvoiceJour):

                   custTable = CustTable::find(CustInvoiceJour::findRecId(testCursor.RecId).InvoiceAccount, false);

                   break;

               case tablenum(ProjInvoiceJour):

                   custTable = CustTable::find(ProjInvoiceJour::findRecId(testCursor.RecId).InvoiceAccount, false);

                   break;

           }

           if (custTable.EInvoice)

           {

               allowEditBasedOnActualForm = true;

           }

       }

    Thanks,

    Maciej

  • Johnkrish Profile Picture
    Johnkrish 781 on at
    RE: How to enable/disable delete button in the Attachment(Document Handling) based on Enum status

    Hi Anand,

    In the document handling form set the Delete button Auto Declaration property to Yes and through code access the button Enabled property.

    for accessing Enum values you have to declare a variable for the enum first, after in if condition you can check.

    Regards,

    John

  • Anand AX Profile Picture
    Anand AX 2,172 on at
    RE: How to enable/disable delete button in the Attachment(Document Handling) based on Enum status

    Hello John,

    I cant get you ..! Can you please explain it in brief? I want to disable delete button in the attachment based on the status field.

  • Johnkrish Profile Picture
    Johnkrish 781 on at
    RE: How to enable/disable delete button in the Attachment(Document Handling) based on Enum status

    Hi Anand,

    If your form template is None, then why cant you try the autodeclaration property Yes and access the button Enabled property.

    Regards,

    Johnkrish

  • Johnkrish Profile Picture
    Johnkrish 781 on at
    RE: How to enable/disable delete button in the Attachment(Document Handling) based on Enum status

    HI Anand,

    This link could be useful.

    dynamicsuser.net/.../164689.aspx

    regards,

    johnkrish

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.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,074 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,900 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans