I add one web resource in form's header.Now based on field value i need to hide. i used the following way but its not working
Method 1 : Xrm.Page.ui.tabs.get("WebResource_name").setVisible(false);
Method 2 : var control = Xrm.Page.ui.controls.get("WebResource_name");
control.setVisible(false);
How can I achieve this ?
Add image in header ,
and I try by using the following code,
function test()
{
Xrm.Page.getControl("WebResource_123").setVisible(false);
}
*This post is locked for comments
Try this code, it worked for me.
function btnHide(navItemSchemaName, VisibleType) {
//debugger;
var navItemSchemaName = "nav_EntityNameToHidefromNavigation";
var VisibleType = "No";
var objNavItem = Xrm.Page.ui.navigation.items.get(navItemSchemaName);
if (objNavItem != null) {
if (VisibleType == "No")
objNavItem.setVisible(false);
else if (VisibleType == "Yes")
objNavItem.setVisible(true);
}
}
It's just a guess but try to recreate a resource with some name starting from letters (like WebResource_Image). Your code works fine for me (the only difference is that I have WebResource_Test name of webresource).
@AndriiButenko @harinarayanan I added some changes in questions for elaborate.
I agree with Hari. Code like
Xrm.Page.getControl("WebResource_<name>").setVisible(false);
should work fine.
Can you please provide exact code you use and screenshot of your webresource configuration where you define its name?
@hari narayanan It shows the Unable to get property 'setVisible' of undefined or null reference error
Please refer the screenshot in the question
You cannot get the header with tabs control so ui.tabs is wrong, but the second piece of code is correct.
var Controls = Xrm.Page.ui.controls.get("your web resource name") or Xrm.Page.getControl("WebResource_<Name>") should work.
Can I have a screenshot please?
I did add yammer image in header by using insert->webresource option from top of the form option.Now i need to hide the image based on lead's firstname
Hello,
Can you please provide a screenshot of a form? Just curious - in what way you've placed webresource to header of a form?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156