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.

2 comments:

  1. Can i set the notescontrol as Required

    ReplyDelete
    Replies
    1. Notes are associated entities and not field so it is impossible to make Notes required. Use field for this purpose.

      Delete