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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to create a new Termination button in the ribbon bar?

(0) ShareShare
ReportReport
Posted on by 26

Hello,

I need to create a button to be able to term the record.  I haven't been able to find anything on how to do this, any ideas?

Thank you.

I have the same question (0)
  • Saad Kabarousse Profile Picture
    734 on at

    Hello,

    What do you mean by Term? Disable?

  • USA80 Profile Picture
    26 on at

    Yes...Disable/Inactive and the record becomes read only.

  • Suggested answer
    Saad Kabarousse Profile Picture
    734 on at

    You can associate a Javascript commande to your button, the Javascript function will fire either a workflow(by updating a field or something, and change the status of ur record using a workflow step)

    or an action(using process. Js and a plugin associated to ur action that will exécute a setstaterequest to enable or disable ur record. ) 

  • USA80 Profile Picture
    26 on at

    Do you have an example on how this can be completed?  

  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    Hi 

    You can use below code if you are adding button in Form

    Create Js webresource

    function check() {
    var entity = {
    "EntityId": Xrm.Page.data.entity.getId().replace("{","").replace("}","") // accountId
    };

    var WorkflowId = "2025DDE0-66E5-47D7-8611-2AD5F3306D69"; // workflowID For getting Workflow Id You can see below image and also what steps you add

    var req = new XMLHttpRequest();
    req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/workflows(" + WorkflowId + ")/Microsoft.Dynamics.CRM.ExecuteWorkflow", true); // mention what version you are using I am using 9.1
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.onreadystatechange = function() {
    if (this.readyState === 4) {
    req.onreadystatechange = null;

    if (this.status === 200) {
    Xrm.Utility.alertDialog("Success");

    Xrm,Page.data.refresh();
    } else {
    Xrm.Utility.alertDialog(this.statusText);
    }
    }
    };
    req.send(JSON.stringify(entity));

    }

    Then Create button in ribbon workbench and use this function to call

    pastedimage1570008569204v2.png


    Hope it helps

  • USA80 Profile Picture
    26 on at

    This does help, however I am on version 9.0 and the code that you used above is being deprecated.  Like Xrm.Page and dialogs.  Correct?  

  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    Hi,

    That code still work but I have changed few 

    function check() {
    var entity = {
    "EntityId": Xrm.Page.data.entity.getId().replace("{","").replace("}","") // accountId
    };

    var WorkflowId = "2025DDE0-66E5-47D7-8611-2AD5F3306D69"; // workflowID For getting Workflow Id You can see below image and also what steps you add

    var req = new XMLHttpRequest();
    req.open("POST", Xrm.Utility.getGlobalContext().getClientUrl() + "/api/data/v9.1/workflows(" + WorkflowId + ")/Microsoft.Dynamics.CRM.ExecuteWorkflow", true); // mention what version you are using I am using 9.1
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.onreadystatechange = function() {
    if (this.readyState === 4) {
    req.onreadystatechange = null;

    if (this.status === 200) {
    Xrm.Navigation.openAlertDialog("Success",null);

    Xrm.Page.data.refresh();
    } else {
    Xrm.Navigation.openAlertDialog('Already inactive or Error',null);
    }
    }
    };
    req.send(JSON.stringify(entity));

    }

    Now Xrm.Page is not been replaced even in this code because we cannot get the formcontext is working for UI or normal web client when we use to call javascript function through ribbon workbench. I also get null value when using from web client. UI its working fine. For that you can check this link for more explaination

    https://stackoverflow.com/questions/48202316/how-to-get-formcontext-in-ribbon-command-of-dynamics-365-9-0

    other than Xrm.Page . I Changed all the deprecated code

    Hope it helps

  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    For me it will not work but if you want to try you can refer this post

    www.magnetismsolutions.com/.../getting-dynamics-365-formcontext-from-ribbon-workbench

    but check for both UI and Web client(classic). it is possible that I had done some minor mistake.

    Hope it helps

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 103 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 83

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans