Showing posts with label Notes. Show all posts
Showing posts with label Notes. Show all posts

Wednesday, October 27, 2010

Disabling Notes for deactivated records MS CRM

In the OnLoad event:




Code Snippet
/* [s] Disables the creation of new Notes, and editing of existing notes. Attachments can still be opened. */
//If the 'Close' button is showing, means that form Status = Resolved or Cancelled
var btnClose = document.getElementById("_MBwindowclose");
if (btnClose != null)
{
//Need to attachEvent, because IFRAME elements load asynchronously, and elements like 'newNoteButton' are not accessible on form load
var iframe = document.getElementById("notescontrol");
iframe.attachEvent('onreadystatechange', DisableNotes);
}
/* [e] */





The function DisableNotes:




Code Snippet
function DisableNotes()
{
//Hide 'Create a New Note' link
window.frames[0].document.getElementById('newNoteButton').style.visibility="Hidden";
var NotesTable = window.frames[0].document.getElementById('NotesTable');
//Disable the entire table
NotesTable.disabled = true;
var TextArea = NotesTable.getElementsByTagName('TEXTAREA');
//It's still necessary to individually disable the Textareas where users edit the existing notes.
for (i=0;i<TextArea.length;i++)
{
TextArea[i].disabled = true;
}

return;
}