views:

923

answers:

2

I'm customising Dynamics CRM 4 and would like to modify the Form for the Case entity to add some JavaScript to the onchange event for the Knowledge Base Article lookup field (kbarticleid_ledit). However, when I click Change Properties for that field I get an error message:

This field belongs to a locked section and cannot have its properties modified.

How can I get around this and edit it? Is there a workaround similar to customizing the Article view? Or can I hack the DB somehow to "unlock" that field?

+2  A: 

OK, I figured it out - posting here in case anyone else runs into the same problem. You need to export the customizations for the Case entity to XML and edit the XML. You can "unlock" the section by finding the corresponding element in the XML and changing the attribute locklevel="1" to locklevel="0".

However, unlocking it didn't help me in editing the onchange event code. CRM already had some code for that event and when I added my code in the UI it added a second "onchange" event to the XML! So I was forced to manually edit the code in the XML (with proper XML-encoding, of course) and then re-import and publish the customizations.

Evgeny
+2  A: 

You could also have added onchange code from the onload event. For example, if the locked field's id was lockedField, you could do something like this.

var field = crmForm.all.lockedField;
if (field)
    field.attachEvent('onchange', onChangeEventHandler);

function onChangeEventHandler()
{
    // do something 
}
Polshgiant
Ah, that's good to know - thanks. I think I'd prefer editing the existing onchange event, though, so I know what order the code executes in.
Evgeny