Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Prompt NoYes on delete - Form menu item button

(1) ShareShare
ReportReport
Posted on by 104
The BOMDesigner form instantly removes the BOMLine when delete button is pressed. Instead, I want to prompt NoYes when the user attempts to delete the record.
Categories:
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,445 Most Valuable Professional on at
    Prompt NoYes on delete - Form menu item button
    BOM lines > Delete in BOMDesigner is a different case. Look into the code (called from clicked()) to see what it does.
    You'll notice that there already is a confirmation dialog that you can enable by setting TmpBOMRouteTree.ConfirmDelete. This is code in BomDesignerCtrl.removeLine():
    if (    tmpBOMRouteTree.ConfirmDelete
        && !Box::yesNo(strFmt("@SYS67139",bomCache.ItemId),DialogButton::No,"@SYS10308","@SYS10308"))
    {
        return;
    }
    
    this.deleteBOM(_nodeIdx);
  • EK-26061005-0 Profile Picture
    EK-26061005-0 104 on at
    Prompt NoYes on delete - Form menu item button
    I have tried the prompting via validateWrite in code extension but it didn't have any effect:
     
    [ExtensionOf(formStr(BOMDesigner))]
    final class BOMDesigner_MYMODEL_Extension
    {
        [DataSource]
        class BOM
        {
            public boolean validateDelete()
            {
                boolean ret;
    
                DialogButton dialoguePick = Box::yesNo("Are you sure you want to delete this record?", DialogButton::No);
    
                if(dialoguePick == DialogButton::No)
                {
                    return false;
                }
    
                ret = next validateWrite();
    
                return ret;
            }
        }
    }
     
  • Layan Jwei Profile Picture
    Layan Jwei 7,349 Super User 2024 Season 2 on at
    Prompt NoYes on delete - Form menu item button
    Hi EK,
     
    I can see you edited the question and changed EcoRes form to BOM designer.
     
    You could still do the same thing somehow.
    You can hide this delete action menu item by code, add a new one, then add code to the clicked method to open the dialog box and if the user clicked yes, you can paste the code from the original delete action menu item clicked method code.
     
    For the EcoRes form, i agree with Martin about the shortcut to delete. 
     
    I was just answering the question on how to implement dialog box in this case.
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,445 Most Valuable Professional on at
    Prompt NoYes on delete - Form menu item button
    The idea of the new button isn't an ideal one, because users can use a keyboard shortcut to delete records. Also, simply using the method intended for this purpose, validateDelete(), will be easier.
  • EK-26061005-0 Profile Picture
    EK-26061005-0 104 on at
    Prompt NoYes on delete - Form menu item button
    @Layan Jwei I apologize for the confusion, the delete button is actually in BOMDesigner form.
     
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 7,349 Super User 2024 Season 2 on at
    Prompt NoYes on delete - Form command button
    Hi,

    1. Create an extension class for the form, and set the "Show delete button" as No
    [ExtensionOf(formStr(EcoResProductDetailsExtended))]
    final class EcoResProductDetailsExtended_Extension
    {
        public void init()
        {
            this.form().design().showDeleteButton(false);
            next init();
        }
    }

    2. Create an extension of the form and create under the "ActionPane" a new button group, and inside this group, add a new command button and set the command property value as "DeleteRecord", this dialog will appear automatically
    (Ignore the namings, I just did it quickly)




    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans