I have updated the solution to pass the relationship name as parameter(query string) to the HTML resource. This way we can use the same HTML web resource as many times as we want.
Here is the updated code for the HTML web resource.
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <style type="text/css">html,body{font-family: Segoe UI, Tahoma, Arial;background-color: #d6e8ff;border: 0px; margin: 0px; padding: 0px;}</style> <script type="text/javascript" language="javascript"> //debugger; //get the context var Xrm = window.parent.Xrm; //get the current object id var oId = Xrm.Page.data.entity.getId(); //get the object type var oType = Xrm.Page.context.getQueryStringParameters().etc; //set Relationship Name var relName = getDataParam(); if (relName != "not found") { //building a url var sUrl = "/userdefined/areas.aspx?oId=" + oId + "&oType=" + oType + "&pagemode=iframe&security=852023&tabSet=" + relName; //get relative path with orgname as required var relativeUrl = Xrm.Page.context.prependOrgName(sUrl); window.location = relativeUrl; } else { noParams(); } //Most of this code is from sdk dataparams example function getDataParam() { //Get the any query string parameters and load them into the vals array var vals = new Array(); if (location.search != "") { vals = location.search.substr(1).split("&"); for (var i in vals) { vals[i] = vals[i].replace(/\+/g, " ").split("="); } //look for the parameter named 'data' and return relationship name for (var i in vals) { if (vals[i][0].toLowerCase() == "data") { var relationship = decodeURIComponent(vals[i][1]) relationship = relationship.replace(/\+/g, " ") return vals[i][1]; }//endif } //end for loop return "not found"; }//endif else { return "not found"; } }// end function function noParams() { var message = document.createElement("p"); message.innerText = "No data parameter was passed to this page"; document.body.appendChild(message); } </script> </head> <body> </body> </html>
How to call HTML web resource
- Add the navigation link to the form. The navigation link properties dialog will look like the following screen shot.
- Choose the name for the navigation link.
- Select an icon for the link.
- Select “External URL” instead of using the web resource. Use the relative path for the web resource and pass the relationship name as query string parameter as shown in the screen shot above.
- Save and publish the changes and test the solution.
Hi!
ReplyDeleteNew Navigation Link is not visible for non admin users. Is there any permissions that should be granted to users?
I'm adding associated Leads view to Campaign. Despite the fact that non-admin user can read all campigns and leads, navigation link is not displayed.