web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

hide web resource from form's header using javascript

(0) ShareShare
ReportReport
Posted on by 1,000

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 ?

2364.Capture.PNG

Add image in header ,

7522.Capture.PNG

and I try by using the following code,

function test()
{
   Xrm.Page.getControl("WebResource_123").setVisible(false);

}

*This post is locked for comments

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Can you please provide a screenshot of a form? Just curious - in what way you've placed webresource to header of a form?

  • vijay12872 Profile Picture
    1,000 on at

    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  

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Can I have a screenshot please?

  • Verified answer
    Hari Narayanan Profile Picture
    589 on at

    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.

  • vijay12872 Profile Picture
    1,000 on at

    Please refer the screenshot in the question

  • vijay12872 Profile Picture
    1,000 on at

    @hari narayanan It shows the Unable to get property 'setVisible' of undefined or null reference error

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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?

  • vijay12872 Profile Picture
    1,000 on at

    @AndriiButenko @harinarayanan  I added some changes in questions for elaborate.

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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).

  • Community Member Profile Picture
    on at

    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);

           }

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans