web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Add custom functionality to standard button

(0) ShareShare
ReportReport
Posted on by

Hi, All.

I must add custom functionality to standard button: extend "delete" button in my custom entity with dialog.

I tried add workflow with trigger on "record is deleted", but I can't run child dialog from workflow.

How I can do it? If in Ribbon - Can I save there are standard "delete" functionality?

 

Thanks.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aileen Gusni Profile Picture
    44,524 on at

    Hi Nataly

    You can create a double action ribbon.

    First of all, it's recommended to create new one and copy the existing button functionality, hide the existing one.

    Then just use ribbon workbench and then from the delete button ribbon just add new action.

    So in the ribbon workbench, just customize the ribbon, customize the command and add new action on it.

    See these as references:

    community.dynamics.com/.../152860.aspx

    crmtipoftheday.com/.../create-a-two-action-ribbon-button

    The example there is modify the existing mail merge button then add new action that is calling the Workflow.

    If in your case you want to call dialog you can refer to this:

    ribbonworkbench.uservoice.com/.../140652-create-a-run-dialog-short-cut-ribbon-button

    Hope this can help you..

    Thank you.

  • Royal King Profile Picture
    27,686 on at

    can provide more info on what exactly you want to do before deleting the record ?

  • Community Member Profile Picture
    on at

    Chitrarasan Duraisamy

    Not before, but after. After deleting the record, I need check all active records from this entity for account (customer from deleting record). And if count = 0 - propose to user delete account too.

  • Community Member Profile Picture
    on at

    I know how to call dialog from custom button. I did it. The main question - how I can save "delete" functionality for button?

  • Verified answer
    Royal King Profile Picture
    27,686 on at

    I would create custom delete button and  hide OOB Delete button . In my custom delete button , once user clicks delete check the number of child record in a customer if the count is 1 , delete the record using script action and show the javascript alert to the user .

    FInd below script that may helpful to get started with implementing the solution. You can call below function in your custom button to delete record and pop message to user if if its last record . You may need to adjust entity name and field schema names

    function deleteRecord() {

       var req = new XMLHttpRequest();

       req.open("GET", encodeURI(Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/AccountSet?$select=AccountId&$top=2"), false);

       req.setRequestHeader("Accept", "application/json");

       req.setRequestHeader("Content-Type", "application/json; charset=utf-8");  

       req.send();

       var returned = JSON.parse(req.responseText).d;

       var count = returned.results.length;

       var req = new XMLHttpRequest();

       req.open("POST", encodeURI(Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'')"), false);

       req.setRequestHeader("Accept", "application/json");

       req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

       req.setRequestHeader("X-HTTP-Method", "DELETE");  

       req.send();

       if(count =1)

       {alert("Delete customer record.")

       }

    }

  • Community Member Profile Picture
    on at

    I created new custom button with two actions.

    First action - standard delete functionality, second - for dialog call.

    As result - I see at the same time both action:


    Loading - standard question for delete, alert with "ggg" - second action. I need to run second function ONLY after deleting, because I did there are check for active record. 

    How I can do it?

  • Royal King Profile Picture
    27,686 on at

    Dont create 2 action button. Create standard custom button with script action , on click of the button it will call the function where you can check the record count as well delete the record and show alert message to user. Refer my previous reply script function.

  • Community Member Profile Picture
    on at

    Chitrarasan Duraisamy


    Thanks, I will try.

    But how I can delete record from javascript? 

  • Royal King Profile Picture
    27,686 on at

    Take a look at script i posted that includes script to get record count ,deleting record  and showing alert message. All you to do is change the entity name and guid of the record that you want to delete

    var req = new XMLHttpRequest();

      req.open("POST", encodeURI(Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'')"), false);

      req.setRequestHeader("Accept", "application/json");

      req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

      req.setRequestHeader("X-HTTP-Method", "DELETE");  

      req.send();

  • Community Member Profile Picture
    on at

    Thanks! It works!

    This is my code:

    function DeleteContractProcessingDialog (dialogId, typeName, recordId)
     { 
    	
    	if (confirm("Do you want to delete this record?")) 
    	{ 
    		var recordId2 =recordId.replace("{", "");
    		recordId2 = recordId2.replace("}", "");                      
    
    		var serverUri =  Xrm.Page.context.getClientUrl() +"/cs/dialog/rundialog.aspx";
    
    		var mypath =  serverUri +'?DialogId=%7b' + dialogId.toUpperCase()  +'%7d&EntityName=' + typeName+'&ObjectId=%7b' +recordId2+'%7d'; 
    		window.showModalDialog(mypath, "DeleteContract", "dialogWidth: 650px; dialogHeight: 400px; resizable: no; status: no, scrollbars:no;");   
    		Xrm.Page.data.refresh();
    	
    		XrmServiceToolkit.Rest.Delete(recordId, "gs1_agreementSet", function () {
    			refreshGrid = true;
    		}, function (e) {
    			XrmServiceToolkit.Common.ShowError(e);
    			isSuccess = false;
    		}, false);
    	}
    	 
    }

    In begin I deleted record and then run dialog. It was mistake. Now I run the dialog (with condition count = 1) and then deleted record.
    And - the last question. How I can move on from form to view? It need after delete...

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans