Wednesday, June 8, 2011

alternate colors in the main grid of ms crm 4.0

Sometimes the requirement used to come as the records in the main grid to be alternate colors as in normal grid controls.
keep it in mind we are going to alter the aspx page provided by MS CRM :P
To achieve it in CRM just needs some JS code.

1. open the HomePage.aspx from the _root folder
2. append a method onload of the body as <body class="stage" onload="alterGridRecords()">
3. now the function alterGridRecords should be as followed

function alterGridRecords(){
var grid = document.getElementById("gridBodyTable").lastChild; //gridBodyTable is the id, wch will help
for (var i = 0; i < grid.childNodes.length; i++)
{
if ((i % 2) == 0) {
grid.childNodes[i].style.backgroundColor = "#EEEEEE"; //put color as per the user requested
grid.childNodes[i].colourised = true;
}
else {
grid.childNodes[i].style.backgroundColor = "#FFFFFF"; //put color as per the user requested
grid.childNodes[i].colourised = true;
}
}
}

this is so simple

one prob in the above is that you will not be able to make the selected records in diff color.
so just a bit twist
grid.childNodes[i].childNodes[2].style.backgroundColor = "#FFFFFF";
this will make alternate colorsonly the 1st column as its being implemented as only one color in ms crm 2011. :P

Tuesday, April 19, 2011

Calling external JS files from MS CRM 4.0 form

function LoadFunction() { }
//create a Script loader object + function to be called when the script has
//finished loading
window.ScriptLibrary = new ScriptLoader(LoadFunction);
//url , false - cache, true - no cache
ScriptLibrary.Load('//FileName.js', true);

Wednesday, February 16, 2011

Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'. The request failed with the error message:

if u will get error message like this while in plugin or else using the sdk for any external application.
make sure the crmserver url is correct.
some times we used to forget to add the port number if its thr.

yes.sudhanshu

Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'. The request failed with the error message:

if u will get error message like this while in plugin or else using the sdk for any external application.
make sure the crmserver url is correct.
some times we used to forget to add the port number if its thr.

yes.sudhanshu

Invalid Action, the selected action was not valid error in ms crm 4.0

If such kind of error Invalid Action, the selected action was not valid in ms crm 4.0 while loggin in or else already logged in and trying to acces any record or doing some action,
then just try to make the MSCRMAsynchronous Service up.
Even if its showing started in the services, just restart it.

This is a way i hv solved.

yes.sudhanshu

Wednesday, February 9, 2011

refreshing continuously the textbox(textarea) in dot net

some times we need to show the status to the user if some log process is going on. also if any exception in that process.
for that if we will write the message to a textbox(textarea), it will look like realtime message as follow.

the textbox(textarea) control name is "txtStatus"
//each time append the new text to the previous text
txtStatus.Text += "Message from the businees logic to be displayed.";
// this main to just update the control , so that the new text will refreshed
txtStatus.Update();

yes.sudhanshu

Getting project current path in dot net

just use this to get the project current path.
soem times we need to create the log folder inside the project path with bin and other folders.
this is in windows application.

string path = Directory.GetParent(Path.GetDirectoryName(Application.StartupPath)).FullName;

yes.sudhanshu

Sunday, January 30, 2011

Organise the NameSpaces in visual studio

Sometimes we used some namespaces and we delete the references. still the using statement will be there. to make it clean we can use a shortcut, which wecan configure as follows.

go to Tools -> Options from visual studio.
Select Keyboard from left items.
then select "Edit.RemoveAndSort"
Now ether the key strokes you like in press Shortcut key text box (suppose ctrl+shift+w).Keep in mind all the three you have to press @ one short.

yes.sudhanshu

Thursday, January 27, 2011

Default look up value with out knowing the GUID only the text in MS CRM 4.0

Hi,

The default lookup can be done clearly and in supported way as in sdk in my othe r link. Default lookup value with GUID.

Some times while working in dev,UAT and prodution and moving from here to there
or if any one deleted the record and recreated again , means in any chance the GUID got changed , then it will not work.
But one thing here is , only one record should be there in the same name.
Even if its unsupported, still very usefull.

document.all.<FieldScemaName>_ledit.value = 'Default Lookup Value';
document.all.<FieldScemaName>_ledit.fireEvent("onblur");
document.all.<FieldScemaName>_ledit.value = '';

Hope it will help many more.

yes.sudhanshu

Thursday, January 20, 2011

Enable Tracing Ms Crm 4.0

Some times we nned to enable the tracing in ms crm server to get the error details.
But do not forget to disable it again after getting the error details , as it will slow down the process.
for the same just follow the link

Enable Tracing