Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer Service forum

Override OOB case button with Multi-Action

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

Following 'https://community.dynamics.com/crm/f/117/t/246006', am trying to override case cancel OOB button in D365 v9.  I check a custom field and only when it is filled , call the OOB fucntion 'CrmService.IncidentRibbon.CommandBarActions.cancel'

 1. Js on the form...

function cancelreasoncasebutton() { //alert("start"); Xrm.Page.getControl("ecr_cancelreason").setVisible(true); var casereason = Xrm.Page.getAttribute("ecr_cancelreason").getValue(); if(casereason == null) { //alert("cancel stage"); Xrm.Page.ui.setFormNotification("Please fill Cancel Reason Field !!.","INFO","emailCheckNotification"); Xrm.Page.getControl("ecr_cancelreason").setNotification("Please Write the reason to cancel the case."); break; //return true; } else { // call CRM OOB function - CrmService.IncidentRibbon.GridCommandActions.cancelCase //CrmService.IncidentRibbon.GridCommandActions.cancelCase(); CrmService.IncidentRibbon.CommandBarActions.cancel(); } }


2. Add the function call in Action (Ribbon workbench)

case.jpg

After publish, When click the cancel button... Does nothing. Am i missing anything? Any pointers?

Br,Jackie

Categories:
  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Override OOB case button with Multi-Action

    Hi,

    This is happening because from the button JS, you are setting the form notification and field notification but you do not have any code/logic to remove the notifications. You can add the below method and register it on change of description/reason field. This will remove the notification from form/ field. Ensure that you use the same text "emailCheckNotification" in both places

    ===============

    function onchangeDescription() {

       var casereason = Xrm.Page.getAttribute("description").getValue();

       if (casereason == null) {

           Xrm.Page.ui.setFormNotification("Please fill Cancel Reason Field !!.", "INFO", "emailCheckNotification");

           Xrm.Page.getControl("description").setNotification("Please Write the reason to cancel the case.");        

       }

       else {

           Xrm.Page.ui.clearFormNotification("emailCheckNotification");

           Xrm.Page.getControl("description").clearNotification()

       }

    }

    ================

    ** Personally I will prefer just an alert instead of showing notification.

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Override OOB case button with Multi-Action

    Thanks Arun for pointers.

    There was an additional  'NaN' step  and break in js... I removed  them & followed according to Ravi's suggestion and it seems to work except : I can't save the record.. after i fill the description/reason field ..

    case1.jpg

    @ Ravi , any step i am missing ?

    thanks in advance

    br,jackie

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Override OOB case button with Multi-Action

    Hi,

    You need to first validate if the function is tied up with the command r not. You can check this by putting just an alert in the function and then see if you get an alert or not. If youa re not getting an alert then the problem is within the command. If you are getting the alert but then the other code is not working then its the code issue. Few things which I noticed that you have break statement added which is not correct. remove that. Also ensure that the field is on the form and is visible.

    I tried the same implementation on my test org for the description field and it worked as expected. On Ribbon workbench, i clicked on edit command and then instead of system javascript web resource and function, I used my custom.

    Refer below-

    ===================

    function cancelreasoncasebutton() {

       alert("start12345");

       debugger;

       Xrm.Page.getControl("description").setVisible(true);

       var casereason = Xrm.Page.getAttribute("description").getValue();

       if (casereason == null) {

           Xrm.Page.ui.setFormNotification("Please fill Cancel Reason Field !!.", "INFO", "emailCheckNotification");

           Xrm.Page.getControl("description").setNotification("Please Write the reason to cancel the case.");        

       }

       else {

            CrmService.IncidentRibbon.CommandBarActions.cancel();

       }

    }

    ==========================

    cancelcaseribbon.png

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,615 on at
    RE: Override OOB case button with Multi-Action

    Hope you did customize command too. Have you tried to put debugger; to see if its invoked at all?

    You can debug for any errors or broken code.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Override OOB case button with Multi-Action

    @Arun : Thanks for the quick reply. The link - community.dynamics.com/.../246006

    And , yes I did selected customized button and also took back up of the solution from sandbox.

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,615 on at
    RE: Override OOB case button with Multi-Action

    Btw, the link in your question is broken.

    Before doing changes, have you right clicked & press "Customize button"? You have to do this always before customizing any OOB button. Also, take a backup before customizing Ribbon workbench.

    Now, you can take a backup from other environment & import to start again.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans