To explain this i take an scenerio that i have a entity, in this i have an custom left navigation pane link which loads an external URL, here i consider that as Google. Now dynamically i want to change that URL to my Blog URL. We can achieve this by the below code:
the function loadIsvArea(Mscrm.CrmUri.create(iframeUrl),false) is responsible for achieving this.
//Get all navigation items for this form.
var items = Xrm.Page.ui.navigation.items.get();
//Go through the list of navigation items.
for (var i in items)
{
//Get the current navigation item in the for loop
var item = items[i];
//Get the label of the current navigation item
var itemLabel = item.getLabel();
//Check if this is the navigation item we are looking for using the label name.
if(itemLabel == "Custom Link")
{
//Get the current navigation item id.
var areaId = item.getId();
//Get navigation element by using the id.
var navElement = document.getElementById(areaId);
//Make sure that the navigation element is not empty or null
if (navElement != null && navElement != undefined)
{
//Create the url to use in the navigation link
var iframeUrl = encodeURI("http://mscrmessentialblog.blogspot.com/");
//Create a function that is run when the navigation link is clicked.
navElement.onclick = function ()
{
//Start by creating the area, this is where the url looses "/report/path" from the path.
loadIsvArea(Mscrm.CrmUri.create(iframeUrl),false);
//Get the iframe in the navigation area.
var navIframeObject = document.getElementById(areaId+"AreaFrame");
//Set the source for the iframe again with the correct url.
navIframeObject.src = iframeUrl;
};
}
}
}
This results as:
No comments:
Post a Comment