28 November 2007

How to change the width of Queue Title column?

QueueItem and its Views are not customizable in CRM v3.0, one requirement was make the Title column wider then users can see more information. (The Title column contains subject of activities/cases)
By default, Title column width = 300px, so how to change it to 500px? Here's my soluiton:

/*
../workplace/home_workplace.aspx
Make the queue title column width = 500px
*/

//1. Edit CRMWeb/workplace/home_workplace.aspx, add a new JavaScript function call: titleWidth()
function titleWidth()
{
var barCols = document.getElementById("crmGrid_gridBarCols");
barCols.getElementsByTagName("COL")[2].width = 500;
crmGrid.Refresh();
}

//2. Call this function from the existing nodeSelect() and window.onload().
function nodeSelect( sQueueId, sViewId, sMenuId )
{
......
titleWidth();
}

function window.onload()
{
......
titleWidth();
}

20 November 2007

Hide/remove/move/change entity level tags at runtime


/* Removing Sub-Account navigation bar at runtime */
if(document.all.navSubAct != null)
{
navSubAct.style.display = 'none';
}

/* Hiding Service Tag at runtime */
if(document.all._NA_CS != null)
{
document.all._NA_CS.style.display = 'none';
}

/* Moving Case under details group at runtime */
if((document.all.navService != null) && (document.all._NA_Info != null))
{
document.all._NA_Info.appendChild(navService);
}

/* Changing group name from 'Sales' to 'Management' */
if (document.all._NA_SFA != null)
{
document.getElementById("_NA_SFA").innerHTML = document.getElementById("_NA_SFA").innerHTML.replace("Sales","Management");
}

14 November 2007

Contact Quick Find: a bug?

In my environment, I have 'fullname', 'lastname', 'firstname' as the Contact 'Quick Find Columns'.
I noticed that the 'quick find' only search contacts from the current result view, not all records(which it should do). To work around this problem, you can edit '\_common\scripts\stage.js'


crmGrid.Reset(); // add this line here

if (crmGrid.GetParameter("viewid") != SavedQuerySelector.quickFindQuery)
{
crmGrid.SetParameter("viewid", SavedQuerySelector.quickFindQuery);
crmGrid.Reset();
}
else
{
crmGrid.PageNumber = 1;
}


To test it, you must firstly delete all Temporary Internet Files on Internet Explorer Options.

11 November 2007

CRM how to hide field / label / line / section / tab


/*hide field only*/
crmForm.all.field.style.display = 'none';

/*hide field and this field's label*/
crmForm.all.field.style.display = 'none';
crmForm.all.field_c.style.display = 'none';

/*hide field and the whole line which contains this field*/
crmForm.all.field.parentElement.parentElement.style.display = 'none';

/*hide field and the section which contains this field*/
crmForm.all.field.parentElement.parentElement.parentElement.style.display = 'none';

/*hide a tab(tab number comes from 0)*/
crmForm.all.tab2Tab.style.display = 'none';

08 November 2007

How to disable / readOnly CRM fields / iframes

Sometimes we need to disable all fields in CRM, so a function could help!
Also, you don't want to diable INPUT/TEXTAREA nodes, because it will become unreadble (gray #808080) if you disable it, so I prefer to set those nodes readOnly. (only INPUT and TEXTAREA support readOnly property!)


/*
setDisabled function
1. set readOnly property for INPUT/TEXTAREA nodes
2. disable other nodes
id: element's Id
ignoreNodes: nodes can be ignored
nodesDisabled: bool, true = set disable/readonly
*/

function setDisabled(id, ignoreNodes, nodesDisabled)
{
var node, nodes;
nodes = id.getElementsByTagName('*');
if(!nodes)
return;

var i = nodes.length;
while (i--)
{
node = nodes[i];
if(node.nodeName && !(node.nodeName.toLowerCase() in ignoreNodes))
{
if((node.nodeName == "INPUT") || (node.nodeName == "TEXTAREA"))
{
node.readOnly = nodesDisabled;
}
else
{
node.disabled = nodesDisabled;
}
}
}
}

/*disable/readonly fields*/
setDisabled(document.getElementById("areaForm"), {table:'', iframe:'', div:'', form:'', col:'', colgroup:'', lable:'', span:'', tbody:'', body:'', tr:'', td:''}, true);

/*disable IFRAME*/
try
{
window.setTimeout(iframeDisabled, 3000);
}
catch(err)
{
alert("System busy, please try again later!" + err);
window.close();
}

function iframeDisabled()
{
setDisabled(document.frames("IFRAME_1").document.getElementById("mnuBar1"),{}, true);
}

05 November 2007

Microsoft CRM: Filter On: Last 30 days

I have been asked how to change the default Filter On from 'Last 30 days' to 'All' in History associated view.

Micrsoft CRM doesn't provide this customisation, and there are no good solutions on the Internet. After 3 hours research for the source, I found a simple solution:
The file you need to modify is: \CRMWeb\_controls\AppGridFilterContainer\AppGridFilterContainer.htc

Open the file by notepad, and search the string : oCallback(oCtrl);
Just add some code above it:


if(oCtrl.DataValue=="LastXDays;30")
{
oCtrl.DataValue = "All";
RefreshGridView();
}

oCallback(oCtrl);


Save and Close, that's it. Next time when you open History, you will see the change.