Friday, November 20, 2009

Enforcing Leaf Node Selection in Select Subject Dialogue Box

Alright... it's been a while, I was planning something major and had to stop blogging, anyways now I am back[Hopefully with a bang] and here is a first scriptlet on CRM.

Recently one of my colleague was facing an issue with Subject Lookup dialogue box. The requirement was to enable selection of only leaf-nodes i.e. any node with a child node should not be selected as a Subject. After little R&D I came up with the following

Edit : \CRMWeb\_controls\lookup\lookupsubject.aspx
In function applyChange
just below the following statement
if currentSubject != ""
{
put this script…
try{
if(document.getElementById(currentSubject.Id).parentNode.parentNode.attributes['isExpanded'])
{
alert('saaary.. saary meri vajah se hai..');
return;
}
}
catch(e)
{
alert('Error in sadu logic of leaf node selection.' + e.message);
}

I was in strange mood so I've put some garbage text in messages, basically first message box notifies end user when S/He tries to select a non-leaf node and the second message box says there was some error with the script.

Seriously, I love CRM and the endless possibilities of unsupported customizations. :) I hope you got the message ... to make it clear, this is unsupported customization and if you end up with a dead fish please DO NOT blame me.

No comments: