Different entities have the notes in the form where the user can add, delete notes and also attach files. If the users are not giving proper titles for these notes then we could see that when notes are created there will be redundant data in the title and footer of the note, which is the name of the owner and the date when the note was created.
This can be fixed, if required in two ways one way is to educate the users to give a proper title so that the redundant data can be removed. Second way is to hide the footer where the same data is displayed again.
Second way is not a supported way in CRM 2011. But we can do this. This has some disadvantages though.
This can be implemented only (as per my knowledge, please let me know otherwise) when the form loads as the notes attribute cannot be modified or we cannot add any on change event for the same attribute. Because of which when the user adds a new note the footer will be visible for the new note and when the user deletes an existing note then all the hidden rows will be visible again. This will last until the form is reloaded so that our code is triggered.
Below is the code which I used to hide the row
function HideNotesFooter() {
//Get the iframe which has the table row which needs to be hided.
var iframe = window.document.getElementById('notescontrol');
//Get the inner document from the iframe object.
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
//Get the list of all elements inside the iframe having the class name 'noteHeader'
var noteHeader = innerDoc.getElementsByClassName('noteHeader');
//Checks whether the noteheader contains any element or not. If it doesnt have any element trigger this function after sometime.
if (noteHeader.length == 0) {
setTimeout(DisableNotes, 1000);
} //End if for length
else { //If it has any element loop through them and hide the respective row from the table.
for (i = 0; i < noteHeader.length; i++) {
if (i % 2 != 0) {
noteHeader[i].style.visibility = 'hidden';
} //End if for modulus
} //End for loop
} //End else
} //Function End
I have used a call to the setTimeout function because some time I could see that the rows to be hided were not available when the script execution was happening.
Hope this helped you.
No comments:
Post a Comment