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)

Cancel Subsequent Actions in Multi-Action Form Button

(1) ShareShare
ReportReport
Posted on by

I recently upgraded to CRM 2016 from 2011. I had a custom script that executed only when the "Resolve Case" button was clicked to validate that certain fields were filled in. This was done by having the script run when the form was saved and checking to see that the saveMode had a value of 5.

Unfortunately this no longer works in CRM 2016 because the saveMode always has a value of 1 during a normal save operation and when resolving the case so I am looking for alternative solutions. 

A potential easy solution is to move the JavaScript to run when the "Resolve Case" button is clicked. I can do this using the ribbon workbench to add an action to the button but what I cannot figure out how to do is cancel the subsequent default action if validation fails so the user cannot continue to close the case. Is this possible? I could also manually call the default script from within my own script but I could not figure out how to do that from CRM  2016 either. If neither of these can work are there any other solutions to validating a case before resolving it?

I have seen that synchronous workflows are an option but there is some extra logic in the JavaScript that is not directly supported by workflows so I would like to avoid that if possible.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    I would suggest to use Ribbon Workbench to override default behavior of Resolve Case action in following way:

    1. Execute your validations and if something wrong - notify user why he can't close the case and just quit code execution.

    2. If validations passed successfully - just call OOB "Resolve Case" function.

    I've implemented exactly the same logic for "Close Opportunity as Won/Lost" and it worked fine for me.

  • gqmulligan Profile Picture
    on at

    Andrew, thanks for the suggestion but I could not get that to work in CRM 2016 as I mentioned. What version are you using? My understanding is with the newer turbo forms you can no longer easily access other JavaScript files like in previous versions where they were available globally. What method are you using to call the default script?

  • ashlega Profile Picture
    34,477 on at

    Btw, there is an alternative here:

    community.dynamics.com/.../150866

    (create a real-time workflow for validations and stop it as cancelled with an error message)

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Here is article how you can customize Standard Buttons - https://ribbonworkbench.uservoice.com/knowledgebase/articles/81981-2-customising-standard-ribbons

    Here is my instance and Case Ribbon opened in Ribbon Workbench:

    0383.Incident.png

    So OOB function name to call OOB "Resolve Case" dialog is Mscrm.CommandBarActions.resolve.

    Good luck and feel free to ask if something is not clear.

  • gqmulligan Profile Picture
    on at

    Thanks Andrew. This is exactly what I needed. Sad to say I had a typo in the function that caused it to fail before and that led me down the wrong path. This does work as expected.

  • Community Member Profile Picture
    on at

    Hello,

    Following your steps, 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. Added the following js to 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.  And add the function call in Action (Ribbon workbench)

    4505.case.jpg

     

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

    Br,Jackie

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