Monday, November 25, 2013

CRM 2011 - Script loading to Client

What I understood was wrong from UR12 for CRM 2011. JScripts mentioned in the forms in a specific order was not loaded to the client in the same order. Its loaded in the order in which the same is received from the server.

There is no guarantee that the dependent scripts mentioned in the form may be loaded after the script which is calling the same.

Thanks scott for this wonderful post.

CRM 2011 - Hide the footer from notes in different entities

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.

Tuesday, November 5, 2013

JavaScript Errors

When our script attempts to perform an action that the system cannot execute a run time error occurs. It will be easy if we can identify the same from the number returned so that a meaningful user friendly message can be passed on to the end user.
Similar is the case for the syntax errors.
Below is the link to msdn site which will give a fair idea on these error numbers and the description.
For Runtime error check here.
For Syntax errors check here.

Configuration for CRM Plugins

CRM plugins are always great feature where we can automate many functionality which we cannot automate from user interface. But almost eve...