how to hide "Add Existing XXXX" button in crm 4.0???
-
2012년 6월 26일 화요일 오전 11:15
Hello all
i have added one i frame that contain related entity of opportunity. look at this picture.
Here is my code for that
//*************** Get Relationship of resource & Team Composition ****************** function getOppsResourceRelationship() { var assocViewer = new AssocViewer("IFRAME_Resources"); if(crmForm.FormType != 1) { /* Optional - crmForm.ObjectId */ assocViewer.ParentId = crmForm.ObjectId; /* Optional - crmForm.ObjectTypeCode */ assocViewer.ParentOtc = crmForm.ObjectTypeCode; /* Mandatory - relationship schema name */ assocViewer.RelationshipName = "new_opportunity_resource"; /* Mandatory - tabset query string parameter */ assocViewer.Tabset = "new_opportunity_resource"; assocViewer.Load(); //FixStylingInFrameSource("IFRAME_Resources"); //!!!!!!!!! remove white border !!!!!!!! var frameName = 'IFRAME_Resources'; var objFrame = document.getElementById(frameName); objFrame.allowTransparency=true; } } //************************* AssocViewer ********************************** function AssocViewer(iframeId) { var av = this; if (crmForm.FormType == 1) { return; } av.IFrame = document.all[iframeId]; if (!av.IFrame) { alert("Iframe " + iframeId + " is missing!"); } var _locAssocOneToMany = null; av.ParentId = crmForm.ObjectId; av.ParentOtc = crmForm.ObjectTypeCode; av.Tabset = null; av.RelationshipName = null; av.Load = function() { if (av.ParentId == null || av.ParentOtc == null || av.Tabset == null || av.RelationshipName == null) { return alert("Missing Parameters: ParentId or ParentOtc or Tabset Name!"); } var security = crmFormSubmit.crmFormSubmitSecurity.value; var path = document.location.pathname.substring(0, document.location.pathname.indexOf("edit.aspx")) + "areas.aspx?"; var server = "http://svt-srv-02:5555"; av.IFrame.src = server + path +"oId=" + av.ParentId + "&oType=" + av.ParentOtc + "&security=" + security + "&tabSet=" + av.Tabset; av.IFrame.onreadystatechange = av.OnIframeReady; } av.OnIframeReady = function() { if (av.IFrame.readyState != 'complete') { return; } av.IFrame.contentWindow.document.body.scroll = "no"; av.IFrame.contentWindow.document.body.childNodes[0].rows[0].cells[0].style.padding = "0px"; _locAssocOneToMany = locAssocOneToMany; locAssocOneToMany = av.locAssocOneToMany; } av.locAssocOneToMany = function(iType, sRelationshipName) { _locAssocOneToMany(iType,sRelationshipName); if (sRelationshipName == av.RelationshipName) { av.IFrame.contentWindow.document.all.crmGrid.Refresh(); } } }
So, How can i hide this Add Existing Team Composition button from that iframe.???Kartik Associative Software engineer, Synoverge Tech Pvt. Ltd. Ahmedabad
모든 응답
-
2012년 6월 26일 화요일 오후 12:01
If you'd never have the situation where a 'Team Composition' record wouldn't be related to an Opportunity, You could make the 'Opportunity' lookup field 'Required' on the Team Composition entity. - This will stop this button from appearing as each 'Team Composition' record should already be associated to an Opportunity.
- 답변으로 제안됨 Oli Ward 2012년 6월 26일 화요일 오후 12:01
-
2012년 6월 26일 화요일 오후 12:10
Hi Oli
Thanks for reply
but i need the relationship between Team Composition and Opportunity and Only displayed in one of the tab of the Opportunity
So, Only way to hide this button is using JavaScript.
I have Tried lot of Way to hide this button i failed.
Do You know the Solution???
Thanks Again
Kartik Associative Software engineer, Synoverge Tech Pvt. Ltd. Ahmedabad
- 편집됨 kartik ghodasara 2012년 6월 26일 화요일 오후 12:11
-
2012년 6월 26일 화요일 오후 12:42
Hi,
Here's the script:
//Script for hide 'Add existing button' HideAddExistingButton('new_contact_test', ['_MBtoplocAssocOneToMany10008newaccountnewkundenrating']); function HideAddExistingButton(relationshipName, buttonToolTip) { var navElement = document.getElementById('nav_' + relationshipName); if (navElement != null) { navElement.onclick = function LoadAreaOverride() { loadArea(relationshipName); HideButton(document.getElementById(relationshipName + 'Frame'), buttonToolTip); } } } function HideButton(Iframe, buttonToolTip) { Iframe.onreadystatechange = function HideTitledButtons() { if (Iframe.readyState == 'complete') { var iFrame = frames[window.event.srcElement.id]; var liElements = iFrame.document.getElementsByTagName('li'); for (var j = 0; j < buttonToolTip.length; j++) { for (var i = 0; i < liElements.length; i++) { if (liElements[i].getAttribute('id') == buttonToolTip[j]) { liElements[i].style.display = 'none'; break; } } } } } }“relationshipName” you can get it from the entity customization, it’s basically the relationship name in between the entities. “buttonToolTip” is the tool tip defined for the add exixting button.
Greets,
Andreas
Andreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010- 답변으로 표시됨 kartik ghodasara 2012년 6월 27일 수요일 오후 12:09
-
2012년 6월 26일 화요일 오후 1:09
Hi Andreas
Do i have to modify the code you have given???
because i have changed relationship name and buttontooltip but it is not working.
And also not giving any error. and i just fount out that LoadAreaOverride Is never called in execution.
Thanks
Kartik Associative Software engineer, Synoverge Tech Pvt. Ltd. Ahmedabad
- 편집됨 kartik ghodasara 2012년 6월 26일 화요일 오후 1:25
- 편집됨 kartik ghodasara 2012년 6월 26일 화요일 오후 1:42
-
2012년 6월 26일 화요일 오후 1:37
Hi,
The code should worked as expected - you have to change the relationshipname and buttontooltip only. I would suggest to "debug" the steps by using alert-statements to see why the code doesn't work.
Is the subgrid directly on the form?
Greets,
Andreas
Andreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010- 편집됨 Andreas Buchinger 2012년 6월 26일 화요일 오후 1:38
-
2012년 6월 26일 화요일 오후 1:47
Hi Andreas
Sub Grid is on the IFrame.
And LoadAreaOverride is never called While execution.
Thanks
Kartik Associative Software engineer, Synoverge Tech Pvt. Ltd. Ahmedabad
-
2012년 6월 26일 화요일 오후 1:50
Hi Andreas
I have modified code as below
HideButton(document.getElementById("IFRAME_Resource"),['_MBtoplocAssocOneToMany10005newopportunityresource']); function HideButton(Iframe, buttonToolTip) { alert('function'); Iframe.onreadystatechange = function HideTitledButtons() { alert('onreadystatechange'); if (Iframe.readyState == 'complete') { var iFrame = frames[window.event.srcElement.id]; var liElements = iFrame.document.getElementsByTagName('li'); for (var j = 0; j < buttonToolTip.length; j++) { for (var i = 0; i < liElements.length; i++) { if (liElements[i].getAttribute('id') == buttonToolTip[j]) { liElements[i].style.display = 'none'; break; } } } } } }
But the execution stop at alert('function')and never go into onreadystatechange event.
So, What's wrong???
Kartik Associative Software engineer, Synoverge Tech Pvt. Ltd. Ahmedabad
- 편집됨 kartik ghodasara 2012년 6월 26일 화요일 오후 1:54
-
2012년 6월 26일 화요일 오후 1:54
Hi,
Are you sure that the variable 'Iframe' isn't null!?
Greets,
Andreas
Andreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010 -
2012년 6월 26일 화요일 오후 2:06
yes, I am sure.
Now i have removed onreadystatechange event
HideButton(document.getElementById("IFRAME_Resources"),['_MBtoplocAssocOneToMany10005newopportunityresource']); function HideButton(Iframe, buttonToolTip) { alert('function'); if (Iframe.readyState == 'complete') { alert("If"); var iFrame = frames[window.event.srcElement.id]; var liElements = iFrame.document.getElementsByTagName('li'); for (var j = 0; j < buttonToolTip.length; j++) { for (var i = 0; i < liElements.length; i++) { if (liElements[i].getAttribute('id') == buttonToolTip[j]) { liElements[i].style.display = 'none'; break; } } } } }but it stopped at window.event.srcelement.id and give me this error.
Kartik Associative Software engineer, Synoverge Tech Pvt. Ltd. Ahmedabad
-
2012년 6월 26일 화요일 오후 3:02
You need the onreadystatechanged-event because the elements of the iframe aren't loaded complete before this.
Look to it that the Iframe name is correct:
document.getElementById(relationshipName + 'Frame')
If you access the correct object, you can also set the eventhandler...
Greets,
Andreas
Andreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010 -
2012년 6월 27일 수요일 오전 4:58
Hi Andreas
I have searched this "RelationshipName + Frame" means "new_oppportunity_resultFrame" in the developer tool but i failed.
My i frame id is "IFRAME_Resources".
Kartik Associative Software engineer, Synoverge Tech Pvt. Ltd. Ahmedabad
- 편집됨 kartik ghodasara 2012년 6월 27일 수요일 오전 4:58
-
2012년 6월 27일 수요일 오전 10:35
Try instead of
document.getElementById("IFRAME_Resources")this
frames["IFRAME_Resources"]
It seems to be that the object which is returned from the function isn't typed as I-frame...
Greets,
Andreas
Andreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010 -
2012년 6월 27일 수요일 오전 10:50
Hi Andread
I have tried using
frames["IFRAME_Resources"]
but i failed look at the code.
HideButton(frames["IFRAME_Resources"],['_MBtoplocAssocOneToMany10005newopportunityresource']); function HideButton(Iframe, buttonToolTip) { alert('function'); alert(Iframe.readyState); ////It gives Undefined if (Iframe.readyState == 'complete') { alert('if'); var iFrame = frames[window.event.srcElement.id]; var liElements = iFrame.document.getElementsByTagName('li'); for (var j = 0; j < buttonToolTip.length; j++) { alert('for 1'); for (var i = 0; i < liElements.length; i++) { alert('for 2'); if (liElements[i].getAttribute('id') == buttonToolTip[j]) { alert('if in for'); liElements[i].style.display = 'none'; break; } } } } }But it is not entered in if loop. means readyState gives value with undefined
Kartik Ghodasara Associative Software engineer, Synoverge Tech Pvt. Ltd. Ahmedabad
- 편집됨 kartik ghodasara 2012년 6월 27일 수요일 오전 10:51
- 편집됨 kartik ghodasara 2012년 6월 27일 수요일 오전 10:51
-
2012년 6월 27일 수요일 오전 11:13
Hi,
OK, let's try another way - replace your function in AssocViewer with that:
av.OnIframeReady = function() { if (av.IFrame.readyState != 'complete') { return; } av.IFrame.contentWindow.document.body.scroll = "no"; av.IFrame.contentWindow.document.body.childNodes[0].rows[0].cells[0].style.padding = "0px"; _locAssocOneToMany = locAssocOneToMany; locAssocOneToMany = av.locAssocOneToMany; var liElements = av.IFrame.document.getElementsByTagName('li'); var buttonToolTip = ["<YourToolTip>"]; for (var j = 0; j < buttonToolTip.length; j++) { for (var i = 0; i < liElements.length; i++) { if (liElements[i].getAttribute('id') == buttonToolTip[j]) { liElements[i].style.display = 'none'; break; } } } }Greets,
Andreas
Andreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010 -
2012년 6월 27일 수요일 오전 11:26
Hi Andreas
I have replaces code as you have said
but i got value of liElelments'is null.
so,second for loop is result in infinite.
Thanks
Kartik Ghodasara Associative Software engineer, Synoverge Tech Pvt. Ltd. Ahmedabad
-
2012년 6월 27일 수요일 오전 11:51
Sorry, my mistake:
var liElements = av.IFrame.contentWindow.document.getElementsByTagname('li');Greets,
Andreas
Andreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010- 답변으로 표시됨 kartik ghodasara 2012년 6월 27일 수요일 오후 12:08
-
2012년 6월 27일 수요일 오후 12:08
Hey Andreas
It's Done
I have changed my whole code form this link :: http://danielcai.blogspot.in/2010/03/mscrm-40-remove-existing-xxxxx-to-this.html
And now it's working fine.
very very much Thank you for your support.
Kartik Ghodasara Associative Software engineer, Synoverge Tech Pvt. Ltd. Ahmedabad
- 답변으로 표시됨 kartik ghodasara 2012년 6월 27일 수요일 오후 12:08