This project is superceded by the new application Dynamics XRM Tools which includes improved features http://dynamicsxrmtools.codeplex.com/
Here I have a CRM 4 to CRM 2011 Javascript Converter tool that helps convert scripts to the latest CRM 2011 Form scripting model. The converter uses an xml file that contains CRM4 and CRM5 nodes which allow the converter to find/replace specific instances of text.
I created this as an aid to help me during upgrades from CRM 4 to CRM 2011, so if you would like to test it against your CRM 2011 javascript web resources after you upgrade from CRM 4 then let me know how it goes.
You can find the tool on codeplex here.
Has this Tool saved you time…
If you have benefited from downloading and using this tool, please feel free to donate an amount of your choice. Thankyou
This is awesome
Glad you like it. soon I will provide some more details about how the matching works and provide some info on the ConversionList.xml codeSnippet formatting for those that would like to add there own. Just remember it is a tool to aid the conversion, you will still need to review and update code that cannot be matched.
Cheers,
hi Rhett,
i downloaded your tool for js conversion, but it not working.. it need any special requirement to install for supporting this.
Hello, Damodaram, The applicaiton is currently compiled using .NET 3.5. Please installed .NET 3.5 or 4 and the application should work.
Thanks,
Rhett
I’ll give it a go. How do you go about using this? Do you do an upgrade from CRM 4 to 2011 beta, and then run the tool?
Hi Michael, yes after you upgrade to CRM 2011 you will find that all of the scripts can be found in Web Resources in the customisation area of CRM. All of the scripts that were accessible via the form events in CRM 4 are held within a single Web Resource javascript file in CRM 2011. I find it easiest to just open a script file, copy the text and paste it into the left hand text area of the tool and then press Convert. I will then review the script in the right hand text area and if it doesn’t require further adjustments i will copy/paste it back into the Web Resource javascript file and save it.
You can take script from CRM 4 form events and convert those too if you would like to see the results though it is much more convenient to process the entire form script from CRM 2011 as all of a form’s script is initially in one javascript file.
My future considerations include the ability to have the tool provide a list of the available Web Resource Javascript files from the CRM 2011 system so the user can select one from within the tool, convert it and then save it back, possibly even allow the user to save the scripts to a file on the local harddrive as well. For the moment the tool has done what I need it to though depending on feedback I may enhance it sooner rather then later.
Thanks
Rhett
Today after testing on a new imported Org in Beta I found that the getXrmAttribute and getXrmControl no longer exist. Microsoft confirmed this and informed me that the getXrmAttribute and getXrmControl Client API shortcuts were removed from CRM 5 CTP 4 and replaced in CRM 2011 with Xrm.Page.getAttribute and Xrm.Page.getControl respectively.
The original CRM 4 to CRM 2011 JavaScript Converter Tool download had the previous version in the ConversionList.xml file and this has now been fixed.
You can either download the latest .zip file or within the ConverionList.xml file perform a find/replace getXrmAttribute and getXrmControl with Xrm.Page.getAttribute and Xrm.Page.getControl respectively.
Apologies for any inconvenience though the Beta SDK still contains the getXrmAttribute and getXrmControl Client API shortcut reference so I updated this as soon as I found the discrepancy.
Microsoft confirmed that the xrmPage object from the Client API was removed from CRM 5 CTP 4 and replaced in CRM 2011 with Xrm.Page.
The original CRM 4 to CRM 2011 JavaScript Converter Tool download had the previous version in the ConversionList.xml file and this has now been fixed.
You can either download the latest .zip file or within the ConverionList.xml file perform a find/replace xrmPage with Xrm.Page.
The Beta SDK documentation still contains the xrmPage Client API reference.
thank u so much for this great post
Cool tool, Rhett!
Cheers, thanks Matt.
Hi Rhett, this is a great tool. I haven’t used it to upgrade a system yet, but one of my new developers, with a CRM 4.0 programming book on his lap, learnt how to script in CRM 2011 by pasting examples from the book into your utility and then referring to the 2011 SDK to brush up on the method!
When I upgrade a CRM 4.0 system to CRM 2011 does the old 4.0 JavaScript still work? That is: is the conversion of the scripting model (1) useful or (2) required?
Hi Neil, thats great that you guys are getting some benefit out of the tool and a nice technique by your developer on ramping up.
The old CRM 4 script will work in CRM 2011 as long as you’ve stay within the CRM 4 Client API and not used “unsupported” script (i.e hiding tabs, etc….). Although I have found some unsupported script still does work where the DOM is referenced like document.geElementById. The good thing about the tool is that you can add any code snippet you’ve used into the ConversionList.xml file and specify what it should be for CRM 2011, this applies more so where the CRM 2011 Client API now supports script where we had to access the DOM in an unsupported way before.
One of the benefits of upgrading CRM 4 scripts is that there is no guarantee that CRM 4 script will be supported in the vNext version. As the method of accessing the CRM WebServices using JavaScript still works you may decide that leaving this for the moment might be more feasible rather then using REST and/or updating to the new EndPoint.
A few other positives include
– Adds new supported functionality for most requested actions (show/hide)
– Xrm.Page will be supported and it will continue to work after upgrades
– Xrm.Page abstracts from the IE DOM so that in the future scripts might be executed in other browsers and rendering technologies.
o For example future possible support for onload events for the Outlook reading pane which is a win32 form. If people are using the supported Xrm.Page client API Microsoft can make sure this works
– Xrm.Page does not use IE specific expando syntax
Thanks for the feedback,
Rhett
Hi Rhett,
This is a fantastic tool. Thanks a lot for sharing it with us.
I have a small issues with the toll:
I am using the following syntax in all my JavaScripts developed for CRM 4.0:
oStatus = crmForm.all.statuscode;
oStatusBefore = crmForm.all.sur_statusbefore;
if(oStatus.DataValue == 3)
{
oStatusBefore.DataValue = “Interrupted”;
}
else if(oStatus.DataValue == 5)
{
oStatusBefore.DataValue = “Postponed”;
}
else
{
oStatusBefore.DataValue = “Pending”;
}
I’ve created the following Snippets:
crmForm.all.|_|;
Xrm.Page.getAttribute(“|_|”);
|_|.DataValue ==

|_|.getValue() ==
|_|.DataValue = |_|;
|_|.getValue() = |_|;
The first snippet works fine but when I insert the second and third ones the tool hungs.
Am I doing something wrong?
Thanks,
Luiz
Hi Luiz, I’m happy your getting some use out of the tool, it’s a huge time saver isn’t it. I have come across the same situation and although I haven’t fully tested it against a number of scripts you can add the following code snippets to the end of the ConversionList.xml file. These need to be at the end of the file as you will need the other snippets to be processed first as these snippets are cut down versions and may result in incorrect conversions if processed first.
<snippet>
<crm4>.DataValue = |_|;</crm4>
<crm5>.setValue(|_|);</crm5>
</snippet>
<snippet>
<crm4>.DataValue</crm4>
<crm5>.getValue()</crm5>
</snippet>
<snippet>
<crm4> = crmForm.all.|_|;</crm4>
<crm5> = Xrm.Page.getAttribute(“|_|”);</crm5>
</snippet>
Let me know how it goes…
Pingback: Richard Knudson’s Microsoft Dynamics CRM Trick Bag
Pingback: What’s New in CRM 2011: Workflows and Web Resources
brill
Cheers Irfan, glad you like.
Pingback: Microsoft CRM 4.0 to CRM 2011 JavaScript Converter Tool « Sven's Microsoft CRM and Windows Phone Blog
Pingback: CRM 2011 – Comparison between CRM 4.0 and CRM2011 script « Hosk's Dynamic CRM 2011 Blog
Pingback: Converting Microsoft Dynamics CRM 4 JavaScript to Microsoft Dynamics CRM 2011 Javascript code converter | Mohamed Ibrahim Mostafa's Blog
Pingback: yuval14
hi,
how to use this tool, I am not getting proper conversion from this tool
Please read the instructions on codeplex to determine how best to use the tool, and also remember the power in this tool is the ability to specify your own conversion syntax using the ConversionList.xml file.
Cheers,
Rhett
Your program doesn’t work. I have both 3.5 and 4 .NET framework versions installed. is there another condition?am I missing something?
Hi allie, not that I am aware of. It is a very simple WPF application using only standard references. You might like to try it only another computer and see if it is just a localised issue on your current computer,
Cheers,
Rhett
hi tnx for your app
i have a problem , i can’t convert crmForm.lenght to crm 2011 javascript.
do you have any ideas?
It’s probably something like document.all.length knowing that crmForm.length is unsupported anyhow so no equivalent in CRM 2011.
Can we get a JS conversion of Dynamics CRM 2015 to 2016 ??
Hi Rhett, how do I get a copy of your excellent “CRM 4 to CRM 2011 JavaScript Converter Tool” nowadays? Supposedly it (or something like it) is available in CrmToolBox, yet I see no mention of it in the “Store” list. Is the original tool still available somewhere for downloading? Thanks