locked
Using Visual Ribbon Editor to change behavior of Delete ribbon button RRS feed

  • Question

  • Hi al,

    Every form have an Delete button to delete form/record.

    Using Visual Ribbon Editor i can see When click on that button it will call onActionMenuClick on form.js.

    So how to change the behavior of that button, because i want to when user click on Delete button on COntact form , it's will display a confirm message, if user click OK -> it's will call  the out-of-box function onActionMenuClick ()

    Any idea for it, please?

    Wednesday, November 14, 2012 7:01 AM

Answers

  • Dear all,

    MY I found the answer is that, add delete button and give it an specific id in customization.xml

    Of course define

    <Actions>

    <JavascriptFunction $werbresource: myjavascriptresource function:myfunction>

    <CrmParameter value="PrimaryEntityTypeCode">

    </JavascriptFunction>

    </Actions> 

    And in my function like this:

    function ,yDeleteFucntion(primaryEntityTypeCode) {

      var message= "ABC"

               var answer = confirm(message);

                // If the user confirms
                if (answer) {
                    // Delete record: Mscrm.FormAction.onActionMenuClick
                    Mscrm.FormAction.onActionMenuClick("delete", primaryEntityTypeCode);
                }
                else {
                    // Else do nothing
                }

    }


    If my question/answer can help you, please give me a points :) ----You may be disappointed if you fail, but you are doomed if you don't try---

    • Marked as answer by AnyMi Friday, November 23, 2012 2:41 AM
    Friday, November 23, 2012 2:41 AM

All replies

  • Hi,

    The standard Delete button already shows a confirmation button that allows you to delete or de-activate the record - do you want to change this dialog?

    You cannot change standard button behaviour with the Visual Ribbon Editor - you need to use the Ribbon: Workbench http://ribbonworkbench.uservoice.com/knowledgebase/articles/71374-1-getting-started-with-the-ribbon-workbench

    1) Create a solution with the Contact entity and a javascript webresource containing your custom delete function

    2) Open the solution in the Ribbon Workbench - Select the 'Form' ribbon.

    3) Right Click on the 'Delete' button and select 'Customise Command' (not customise button!)

    4) Find the 'Mscrm.DeletePrimaryRecord' command in the 'Solution Elements' panel

    5) Change the Javascript Action to point to your custom function (rather than onActionMenuClick) and select the webresource that contains the function in the 'Library' Lookup.


    Scott


    Scott Durow
    Read my blog: www.develop1.net/public     Follow Me on Twitter
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Tuesday, November 20, 2012 5:50 PM
    Answerer
  • Dear all,

    MY I found the answer is that, add delete button and give it an specific id in customization.xml

    Of course define

    <Actions>

    <JavascriptFunction $werbresource: myjavascriptresource function:myfunction>

    <CrmParameter value="PrimaryEntityTypeCode">

    </JavascriptFunction>

    </Actions> 

    And in my function like this:

    function ,yDeleteFucntion(primaryEntityTypeCode) {

      var message= "ABC"

               var answer = confirm(message);

                // If the user confirms
                if (answer) {
                    // Delete record: Mscrm.FormAction.onActionMenuClick
                    Mscrm.FormAction.onActionMenuClick("delete", primaryEntityTypeCode);
                }
                else {
                    // Else do nothing
                }

    }


    If my question/answer can help you, please give me a points :) ----You may be disappointed if you fail, but you are doomed if you don't try---

    • Marked as answer by AnyMi Friday, November 23, 2012 2:41 AM
    Friday, November 23, 2012 2:41 AM
  • Great - thanks for posting your solution!

    Scott Durow
    Read my blog: www.develop1.net/public     Follow Me on Twitter
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Friday, November 23, 2012 8:14 AM
    Answerer