Wednesday, February 08, 2012

CRM 2011: Playing with notes control

If you want for some reason to allow/disallow user to insert or edit notes in Microsoft Dynamics CRM 2011 following code can help you:

function FormatNotesControl(AllowInsert, AllowEdit)
{
var notescontrol = document.getElementById('notescontrol');
if (notescontrol == null)
return;
var url = notescontrol.src;

if (!AllowInsert)
url = url.replace("EnableInsert=true", "EnableInsert=false");
if (!AllowEdit)
url = url.replace("EnableInlineEdit=true", "EnableInlineEdit=false");

notescontrol.src = url;
}

function DisableNotesInsert()
{
FormatNotesControl(false, true);
}


Copy script, insert it to webresource, add this webresource to required form and call it during onload/onchange of form. And you should not forget that this script is unsupported because it uses document object and it's methods.