Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

hide web resource from form's header using javascript

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: hide web resource from form's header using javascript

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

           }

    }

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: hide web resource from form's header using javascript

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

  • vijay12872 Profile Picture
    vijay12872 1,000 on at
    RE: hide web resource from form's header using javascript

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

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: hide web resource from form's header using javascript

    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
    vijay12872 1,000 on at
    RE: hide web resource from form's header using javascript

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

  • vijay12872 Profile Picture
    vijay12872 1,000 on at
    RE: hide web resource from form's header using javascript

    Please refer the screenshot in the question

  • Verified answer
    Hari Narayanan Profile Picture
    Hari Narayanan 589 on at
    RE: hide web resource from form's header using javascript

    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.

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: hide web resource from form's header using javascript

    Can I have a screenshot please?

  • vijay12872 Profile Picture
    vijay12872 1,000 on at
    RE: hide web resource from form's header using javascript

    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
    a33ik 84,323 Most Valuable Professional on at
    RE: hide web resource from form's header using javascript

    Hello,

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans