Fun with JScript - Cloning a Case aka How do I have a "Master" Case with Microsoft CRM 3

So recently on one of our internal discussion aliases, somebody asked about how to have a master case with a number of “sub-cases.” This is handy when you have a number of issues like a service outage or patch that doesn’t quite apply as desired. J

So in thinking about the problem, I cheated… In class 8525A, we have a tutorial that teaches you how to Clone a Contact. After thinking about it for a few minutes, what is really the business issue? So you want the ability to create a number of cases quickly and tie them all back to a master case.

So to meet this need, here where a few things I did to give you an idea how to do you could do this for a customer. Again, this is inspiration, not a step by step instruction manual. I would better term this as “Demo Ware.” Your actual mileage may vary. Code is available below in the attachments area. (Or clicking here.

Picture of Master Case

Picture of Cloned Case

  1. Create Two Fields
    1. One called NewMasterCase, which will be a Bit Field
    2. One called New_MasterTicketNumber, which is a nvar 100 field.
  2. Add the two fields to the case form. I would make the bit field a check box and the case number should be disabled.
  3. Open the Web.Config File and change the ISV Config portion to “All”.
  4. Copy the enclosed ISV.Config to the C:\Program Files\Microsoft CRM Server\CRMWeb\_Resources\ directory. (I am assuming you are using the demo VPC, if not, your actual directory may differ.)
    1. If you already have modified your ISV.Config file, just change yours with the Incident Entity. (Assuming again that if you have a modified ISV Config, you have a clue what you are doing. J)
  5. Copy the CloneCase.htm file to C:\Program Files\Microsoft CRM Server\CRMWeb\CloneCase\ Directory. (You may have to create the CloneCase Directory.)
  6. Publish Changes.

Now this should work out of the box. If you have additional fields and you want to modify this and you don’t want to read the comments, here is a line:

new_masterticketnumber.DataValue = oSource.ticketnumber.DataValue;

So in this case new_masterticketnumber is the field on the cloned case, where as oSource.ticketnumber.DataValue is the original case field. (So if you wanted the Title field to be copied, that line would look like:

title.DataValue = oSource.title.DataValue;

If you don’t a field mapped, simply comment that line out with “//” which will remove the field from the mappings.

This code will not work as is. You HAVE to create those two fields otherwise, you will get an error message.

This could also be handy in cloning quotes, opportunities, products and much more. What uses could you see for it?

Enjoy!   

 

April 11th Update - Added Matt's Changes below

CloneCase.zip