2

After a successful upgrade from CRM 4 to CRM 2011 everything is working fine except we keep getting javascript onload errors in almost all dialogs including lookup ones. for example when clicking the new button of the contacts the dialog appears and works fine but it shows this error: There was an error in the fields customized event. field:window event:onload error:object doesn't support this property or method.

The old crm 4 system was not customized at all. and no custom javascript code was made to any part of it.

Thank you in advance

I tried to debug the problem for one of the entities and found the error happens in this script:

var _formHierarchy =     '\x7b\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22tab\x22,\x22id\x22\x3a\x22\x7be92df784-47af-48cf-a9cb-ee4811b87d10\x7d\x22,\x22name\x22\x3a\x22task\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22column\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22section\x22,\x22id\x22\x3a\x22\x7bea054020-22ab-4178-aeb7-3d664d96f88c\x7d\x22,\x22name\x22\x3a\x22task description\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22cell\x22,\x22id\x22\x3a\x22\x7b7bd07330-cc88-4056-acd1-dede64bcf1ca\x7d\x22,\x22child\x22\x3a\x7b\x22id\x22\x3a\x22subject\x22,\x22name\x22\x3a\x22subject\x22,\x22controlType\x22\x3a0\x7d\x7d\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22cell\x22,\x22id\x22\x3a\x22\x7b0fde8ba1-0edc-4953-b03d-51aca06cf83c\x7d\x22,\x22child\x22\x3a\x7b\x22id\x22\x3a\x22description\x22,\x22name\x22\x3a\x22description\x22,\x22controlType\x22\x3a0\x7d\x7d\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x5d\x7d\x5d\x7d,\x7b\x22__type\x22\x3a\x22section\x22,\x22id\x22\x3a\x22\x7bE8A0A1AE-3F40-471e-B06E-B221779CA511\x7d\x22,\x22name\x22\x3a\x22task details\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22cell\x22,\x22id\x22\x3a\x22\x7baf141e99-5e42-4650-8e41-851d2128c4bf\x7d\x22,\x22child\x22\x3a\x7b\x22id\x22\x3a\x22regardingobjectid\x22,\x22name\x22\x3a\x22regardingobjectid\x22,\x22controlType\x22\x3a3\x7d\x7d\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22cell\x22,\x22id\x22\x3a\x22\x7b19816b9b-a8fc-4f92-818e-0a8c599f4107\x7d\x22,\x22child\x22\x3a\x7b\x22id\x22\x3a\x22ownerid\x22,\x22name\x22\x3a\x22ownerid\x22,\x22controlType\x22\x3a3\x7d\x7d\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22cell\x22,\x22id\x22\x3a\x22\x7b4ad7b570-173d-4202-855d-0029ec5d40bc\x7d\x22,\x22child\x22\x3a\x7b\x22id\x22\x3a\x22actualdurationminutes\x22,\x22name\x22\x3a\x22actualdurationminutes\x22,\x22controlType\x22\x3a0\x7d\x7d,\x7b\x22__type\x22\x3a\x22cell\x22,\x22id\x22\x3a\x22\x7b05145c34-364e-4cb6-ac01-de4abbec3949\x7d\x22,\x22child\x22\x3a\x7b\x22id\x22\x3a\x22prioritycode\x22,\x22name\x22\x3a\x22prioritycode\x22,\x22controlType\x22\x3a4\x7d\x7d\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22cell\x22,\x22id\x22\x3a\x22\x7bcadc5253-c482-41f3-bd19-da0bf50c3274\x7d\x22,\x22child\x22\x3a\x7b\x22id\x22\x3a\x22scheduledend\x22,\x22name\x22\x3a\x22scheduledend\x22,\x22controlType\x22\x3a0\x7d\x7d,\x7b\x22__type\x22\x3a\x22cell\x22,\x22id\x22\x3a\x22\x7b5c548ccb-ea01-4ba8-bfa4-cef228e30aa6\x7d\x22,\x22child\x22\x3anull\x7d\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22cell\x22,\x22id\x22\x3a\x22\x7b61b62079-b04f-421a-997b-8b84164b54e7\x7d\x22,\x22child\x22\x3a\x7b\x22id\x22\x3a\x22category\x22,\x22name\x22\x3a\x22category\x22,\x22controlType\x22\x3a0\x7d\x7d,\x7b\x22__type\x22\x3a\x22cell\x22,\x22id\x22\x3a\x22\x7bb200a0b7-a0d5-4eef-8b9c-8da47e7945fc\x7d\x22,\x22child\x22\x3a\x7b\x22id\x22\x3a\x22subcategory\x22,\x22name\x22\x3a\x22subcategory\x22,\x22controlType\x22\x3a0\x7d\x7d\x5d\x7d\x5d\x7d\x5d\x7d\x5d\x7d,\x7b\x22__type\x22\x3a\x22tab\x22,\x22id\x22\x3a\x22\x7bD87E07A3-11DA-4b8e-A8CC-F069EBC43FD4\x7d\x22,\x22name\x22\x3a\x22notes\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22column\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22section\x22,\x22id\x22\x3a\x22\x7b81A8A668-2716-4129-846D-E663546EC4FE\x7d\x22,\x22name\x22\x3a\x22notes\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x7b\x22__type\x22\x3a\x22cell\x22,\x22id\x22\x3a\x22\x7b169ed329-a2f4-43b6-8149-17df52f49381\x7d\x22,\x22child\x22\x3a\x7b\x22id\x22\x3a\x22notescontrol\x22,\x22name\x22\x3anull,\x22controlType\x22\x3a0\x7d\x7d\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x5d\x7d,\x7b\x22__type\x22\x3a\x22row\x22,\x22children\x22\x3a\x5b\x5d\x7d\x5d\x7d\x5d\x7d\x5d\x7d\x5d\x7d';
Sys.Application.add_load(crmFormOnLoadHandler);
function crmFormOnLoadHandler()
{

  window.setTimeout('crmForm_window_onload_handler\x28Xrm.Page.ui\x29', 0);
}

function displayError(controlName, eventName, errorDescription)
{
alert('There was an error with this field\x27s customized event.' + '\n\n' +    'Field\x3a' + controlName + '\n\n' + 'Event\x3a' + eventName + '\n\n' + 'Error\x3a' +   errorDescription);
}

function crmForm_window_onload_handler(eventObj,eventArgs)
{

try
{
var   eContext=Mscrm.FormUtility.constructExecutionObject(eventObj,0,null,null);
    eContext=Mscrm.FormUtility.constructExecutionObject(eventObj,0,null,eContext)
    Mscrm.Form_onload();

}
catch(e)
{
displayError('window', 'onload', e.description);

}
if(Mscrm.ClientApiConstants!=null&&Mscrm.ClientApiConstants.primaryEntityId!=null){var     oPrimaryEntity = $find(Mscrm.ClientApiConstants.primaryEntityId);if(oPrimaryEntity!=null)     {initialFormXml=oPrimaryEntity.serialize(Mscrm.SerializationMode.onlyDirtyValues);}}}

the line Mscrm.Form_onload(); is what causing the error to happen. the file is called formscript.js.aspx

ziwar
  • 63
  • 1
  • 9

5 Answers5

3

Check this webpage. We had the same issue and it ends up with IIS 7.0 not install correctly. We need to re-install the RewriteModule (which is included in the CRM install CD) http://blogs.msdn.com/b/emeadcrmsupport/archive/2011/08/31/crm-2011-form-errors-when-opening-non-customised-forms-object-doesn-t-support-property-or-method-form-load.aspx

Victor Sun
  • 46
  • 2
1

It was a server side problem. I don't know exactly why it happens. we also tried to do an installation repair but that didn't solve it. Finally, we installed a fresh CRM 2011 copy on a new server, imported the database and ran Data migration manager. and the error disappeared.

ziwar
  • 63
  • 1
  • 9
0

After you open your form, go to the Customize tab at the top and choose Customize Form. On the form customization page, click Form Properties. Do you see any libraries listed in the first grid? If so, then there probably was some custom JavaScript written for the 4.0 environment that you didn't know about. You can either edit the libraries or remove them. Save, then publish.

Polshgiant
  • 3,595
  • 1
  • 22
  • 25
  • No there is no libraries there, besides this does not happen in only one form... it also appears for example when i open **Customize This System** dialog in the customization section, or when i click pricelist lookup. – ziwar May 03 '11 at 09:48
  • If you have IE8 or IE9 available to you, open a page that throws one of the errors -> press F12 to open the dev tools -> click on Script tab -> click Start debugging -> refresh page. If there is a script error of some sort, the dev tools will stop on it and you can inspect it. If the dev tools don't stop on an error, that usually means there is a syntax error somewhere. In that case, I would suggest you compare your web.config to CRM's out of the box web.config to see if there are any injector modules running that might be causing the trouble. – Polshgiant May 03 '11 at 09:59
  • I actually tried to use dev tools debugger to get the actual error that happens behind the scene, but with no luck. it doesn't stop for the error anywhere... i'll try to check the web configs as you suggested. – ziwar May 03 '11 at 10:09
  • Close IE, install Fiddler on your machine, open Fiddler, open CRM in IE. When you see the prompt about the script error, leave it up and flip over to Fiddler. Are any of the sessions listed in the left pane red? If so, troubleshoot those requests. If not, when you flip over to Fiddler, inspect the last few sessions listed on the left. Does the response to those requests appear to have normal looking content? (Remember, not to dismiss the error message in IE). – Polshgiant May 03 '11 at 12:15
  • OK, I get a few 404 results for the following files: {url}/%7B634374628890000000%7D/WebResources/Application_ribbon.js {url}/%7B634374628890000000%7D/WebResources/Ribbon_main_system_library.js and because it was new task form i got this: {url}/%7B634374628890000000%7D/WebResources/Task_main_system_library.js – ziwar May 03 '11 at 13:24
  • From the looks of it, you did have some JavaScript in your 4 system. And it appears as if the web resources don't exist in CRM anymore. Open the default solution by going to Settings -> Customizations -> Customize the System (note that the default solution isn't visible in the solutions grid). My guess is that you will not find Application_ribbon.js or Ribbon_main_system_library.js listed as Web Resources. Unfortunately, I'm not sure what to recommend after that. There's probably something you could export to manually remove the references to those scripts, but I'm not sure what. – Polshgiant May 03 '11 at 19:34
  • is there any way to create these resources as empty resources? – ziwar May 04 '11 at 03:25
  • by the way, Application_ribbon.js does exist in web resources... but i couldn't find the other files. – ziwar May 04 '11 at 05:58
  • when I double click the Application_ribbbon.js resource from customization page and click text editor button, i get the following js code: `function Mscrm_Isv_Global_Group1_Control0_Group2_Control0_1(){alert('test');}function Mscrm_Isv_Global_Group2_Control0_2(){alert('test');}function Mscrm_Isv_Global_Group3_Control0_3(){alert('test');}function Mscrm_Isv_Global_Group3_Control1_4(){alert('test');}function Mscrm_Isv_Global_Group3_Control2_5(){alert('test');}` – ziwar May 04 '11 at 06:11
0

Do you have cleared the cache of your browser? Maybe an old script of Dynamics CRM 4 is still cached and used instead the new one.

ccellar
  • 10,326
  • 2
  • 38
  • 56
  • I did clear the cache many times and also deleted all browser history and temporary files. this issue is not happening in my laptop only... its happening to all employees of the company. – ziwar May 03 '11 at 10:35
0

It might be helpful to run your code through this tool by Rhett Clinton. It worked well for me on my first 4.0 to 2011 project and the conversions were a good reference for future JavaScript migrations.

Paul
  • 1,590
  • 5
  • 20
  • 41
  • dpii, there is no code to run it... the system was not customized and if you open the entities forms you won't find any js library or code in there, besides, and the error happens in system forms also such as **Customize this system** form. – ziwar May 05 '11 at 03:02