MSCRM 4 - Remove 'Add Existing xxxxx to this record' button
2009-04-02 14:48
253 查看
i 've been working on a MS CRM 4 project and found that the custom
entities that we added displayed an 'Add Existing xxxxx to this record'
button when it was not required and created a lot of confusion amoung
the users.
Microsoft have said they will make this optional 'In the next release' but that is not soon enough for me!
After
working through various ideas on how to solve this with Ian Crowther
and Steve Vallance we came up with the following fix. Thanks also to
'Dynamic Methods' for this post about hiding buttons: http://dmcrm.blogspot.com/2008/01/hiding-buttons-in-mscrm-40.html This
javascript should be added to the onLoad event of the entity where you
are having the problem. You then need to call the function
removeExistingButton passing in the name of the dataArea div tag and
the title of the button you need to remove. (this can be found by using
the IE Developer toolbar):
HideAssociatedViewButton('esp_account_esp_shippingmark', 'Add existing Shipping Mark to this record');
function HideAssociatedViewButton(loadAreaId, buttonTitle)
{
var navElement = document.getElementById('nav_' + loadAreaId);
if (navElement != null)
{
//覆蓋原來的onclick
navElement.onclick = function LoadAreaOverride()
{
// Call the original method to launch the navigation link
loadArea(loadAreaId);
//我們新加的部份
var associatedViewIFrame = document.getElementById(loadAreaId + 'Frame');
if (associatedViewIFrame != null)
{
associatedViewIFrame.onreadystatechange = function HideTitledButton()
{
//完成狀態的話,才去把Button去掉
if (associatedViewIFrame.readyState == 'complete')
{
var iFrame = frames[window.event.srcElement.id];
var liElements = iFrame.document.getElementsByTagName('li');
for (var i = 0; i < liElements.length; i++)
{
if (liElements[i].getAttribute('title') == buttonTitle)
{
liElements[i].style.display = 'none';
break;
}
}
}
}
}
}
}
}
This weeks post comes from one of my co-workers. We've set up a number
of solutions for clients where we hide a custom button or even the
"Convert Lead" button.
If you have hidden buttons in CRM 3.0 you
know that the getElementById method is used to find the Id of the
button you want to hide and then you use DHTML to hide the button.
In
CRM 4.0 there is some auto-incremented number or randomly generated
number that gets placed at the end of all of the ElementId's on a page.
Which means that the code used for CRM 3.0 will break.
The
solution we found for this is to use the "title" tag, which is linked
to the tooltip of your buttons. Here's the code we used to hide a
custom button we wrote to map out driving directions to a client:
entities that we added displayed an 'Add Existing xxxxx to this record'
button when it was not required and created a lot of confusion amoung
the users.
Microsoft have said they will make this optional 'In the next release' but that is not soon enough for me!
After
working through various ideas on how to solve this with Ian Crowther
and Steve Vallance we came up with the following fix. Thanks also to
'Dynamic Methods' for this post about hiding buttons: http://dmcrm.blogspot.com/2008/01/hiding-buttons-in-mscrm-40.html This
javascript should be added to the onLoad event of the entity where you
are having the problem. You then need to call the function
removeExistingButton passing in the name of the dataArea div tag and
the title of the button you need to remove. (this can be found by using
the IE Developer toolbar):
HideAssociatedViewButton('esp_account_esp_shippingmark', 'Add existing Shipping Mark to this record');
function HideAssociatedViewButton(loadAreaId, buttonTitle)
{
var navElement = document.getElementById('nav_' + loadAreaId);
if (navElement != null)
{
//覆蓋原來的onclick
navElement.onclick = function LoadAreaOverride()
{
// Call the original method to launch the navigation link
loadArea(loadAreaId);
//我們新加的部份
var associatedViewIFrame = document.getElementById(loadAreaId + 'Frame');
if (associatedViewIFrame != null)
{
associatedViewIFrame.onreadystatechange = function HideTitledButton()
{
//完成狀態的話,才去把Button去掉
if (associatedViewIFrame.readyState == 'complete')
{
var iFrame = frames[window.event.srcElement.id];
var liElements = iFrame.document.getElementsByTagName('li');
for (var i = 0; i < liElements.length; i++)
{
if (liElements[i].getAttribute('title') == buttonTitle)
{
liElements[i].style.display = 'none';
break;
}
}
}
}
}
}
}
}
This weeks post comes from one of my co-workers. We've set up a number
of solutions for clients where we hide a custom button or even the
"Convert Lead" button.
If you have hidden buttons in CRM 3.0 you
know that the getElementById method is used to find the Id of the
button you want to hide and then you use DHTML to hide the button.
In
CRM 4.0 there is some auto-incremented number or randomly generated
number that gets placed at the end of all of the ElementId's on a page.
Which means that the code used for CRM 3.0 will break.
The
solution we found for this is to use the "title" tag, which is linked
to the tooltip of your buttons. Here's the code we used to hide a
custom button we wrote to map out driving directions to a client:
相关文章推荐
- HTML codes: How do I add a "click here to refresh this page" button on my webpage
- How to disable button in Add/Remove Programs?
- This example uses the Delete method to remove a specified record from a Recordset.
- Failed to start the database service MSSQL$OfficeServers. Repair this product using Add/Remove Programs
- VB保存工程后弹出的add this project to sourcesafe问题处理
- How to add a button to PreferenceScreen
- i.MX Yocto Project: How do I add an existing package to an image?
- How to add customized button to SM30.
- 错误:created a ThreadLocal with key of type ……but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
- How to properly uninstall VERITAS Backup Exec (tm) 9.x if problems occur using Add/Remove Programs
- 给按钮添加 toSearch_Button.setOnClickListener(this);出错 解决办法
- [Resolved] TF254006: No usable accounts are present in your configuration database. Use TfsConfig accounts /add to add an account and return to this wizard.
- How To Quickly Add/Remove Column Statistics (Histograms) For A Column (文档 ID 390249.1
- VC++ Unable to register this add-in because its DllRegisterServer returns an error 解决方案
- Using jQuery to add a dynamic “Back To Top” floating button with smooth scroll
- linux tenserflow add traning picture dataset to TFRecord
- How To Use A Launchpad PPA (Add, Remove, Purge, Disable) In Ubuntu
- VC6插件安装--Unable to register this add-in because its DllRegisterServer returns an error
- How to solve “add/remove operation is impossible, because the code element 'Cxxx' is read only” With
- VC++ Unable to register this add-in because its DllRegisterServer returns an error 解决方案