Sunday, January 13, 2013

MS CRM 2011: How to override standard dialogs

My customer wanted to remove (or hide) “Total Time” and “Billable Time” fields in Case Close dialog window:


Of course I knew that it is possible to open file CRM_Installation_Directory'\CRMWeb\CS\cases\dlg_closecase.aspx, add several lines of code and hide fields and labels but this obvious and easiest way out had 2 disadvantages:
1. This solution is unsupported and it could be broken with new Rollups.
2. This solution would not work for CRM Online.
So I decided to solve this task using supported approaches.
Step 1. Create new solution and put Case entity inside:



Step 2. Write JavaScript that will do the same work as original dialog does (the best way is to use SOAP Logger application to get correct request/response xml) and add it to solution.
Step 3: Create dialog to be used instead of standard one and add it to solution. Your solution solution should look like following:


Step 4: Remove original “Close Case” and create new “Close Case” button using Ribbon Customization. I usually do it using Ribbon Workbench:

 
 

 Publish changes that you’ve done. Demonstration:

UPD Because I have been asked about source code of solution I uploaded it to skydrive and it is available for download here:

33 comments:

  1. Andrii, this is brilliant, very well done, thanks!

    ReplyDelete
  2. Great job Andrii, can you share the javascript and the htm web resources please ?

    Zoran

    ReplyDelete
    Replies
    1. Hello Zoran,

      Send me an email, I will reply with attachments.

      Kind regards,
      Andrii.

      Delete
    2. You can send me an email on:
      ivanov.zoran@gmail.com

      thanks,
      Zoran

      Delete
  3. If possible can I receive a copy also at,

    richard.olivery@gmail.com

    Thanks
    Richard

    ReplyDelete
  4. If possible can i receive the javascript and webresource file?
    topcl.biz@gmail.com

    thanks,
    topcl

    ReplyDelete
    Replies
    1. Hi Andri , I need to explorer similar kind of customization required in Opportunity Close that is one of my client requirement ...if possible can you share this code with me ?

      satheshraman@gmail.com

      Delete
    2. Great Stuff Andrii, I also have same similar requirement related to Opportunity Close. Could you share same code as Sathesh please. Thank you.

      Delete
    3. Hello,

      Recheck the end of post - I've put reference to Skydrive where I've stored solution. Do you see it?

      Kind regards,
      Andrii.

      Delete
    4. Thank you very much Andrii..

      Delete
    5. Oh, yes, I see the files. Thanks

      Delete
  5. Good idea but I would suggest a simpler way. Create a CRM dialog and load that instead of the default dialog when the resolve button is pressed.

    ReplyDelete
    Replies
    1. Hello Syl,

      Thanks! I thought about suggested approach but one thing I was not able to do is dynamically fill optionset with status codes available for incident entity. Do you know how to do that?

      Kind regards,
      Andrii.

      Delete
    2. Not sure doing it dynamically is worth it. Status Codes dont change that often.

      Still, you could do this in the js that launches the dialog :

      1) Check if the list of status codes changed.
      2) If so update a global option set on which your Resolve case Dialog is based.
      3) Launch your Resolve Case dialog.


      If for some reason this behavior is still desired then you would have to add some js code that fires before you load the Dialog and verifys if the list of status codes changed.

      Delete
    3. You might also build a Custom Activity Workflow that would update the option set as the first step of your dialog.

      Delete
    4. Hello Syl,

      You are right, dialog can be used but If I'm not wrong anyway you would not be able to create incident resolution activity that is created during closing of incident. So you would not be able to close incident with proper fields mapping like description, resolution and so on.

      Regarding custom workflow activity - at the moment it can be used but closing of incident would be done asynchronously and you will see the result only after some period of time.

      Kind regards,
      Andrii.

      Delete
  6. This is awesome, Great Job Andrii!!!

    ReplyDelete
  7. Great Job Andrii,

    Sometime we do not want the resolve case dialog box itself.
    I have written one post on my blog "How can be overwrite the resolve Case System ribbon button functionality?".
    http://microxrm.blogspot.in/2013/01/overwrite-resolve-case-system-ribbon.html

    ReplyDelete
    Replies
    1. Hello Mohammad,
      Your article looks great, but you've used a plugin in your functionality. I believe that task can be completed without this step. I have already done this before and I will publish article soon how to do that.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. Thanks Andrii,

      I believe you will come up with better solution.

      Delete
  8. Something original. Love your work. Keep it up.

    ReplyDelete
  9. Can you Please sent the Javascript to me also . "athulmt@gmail.com"

    Thanks in Advance !!

    ReplyDelete
    Replies
    1. Hello Athul,
      Recheck the bottom of post - it has reference to SkyDrive where you can download source code.

      Delete
  10. Hello Andrii,
    I am getting an error when i am trying to import the solution.The error says the there are missing files which are : msa_partnercontactid of type field ,msa_contact_incident of type relationship,msa_contact_Incident of type relationship

    thanks a lot :)

    ReplyDelete