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/show Header field using Javascript CRM 2013

(0) ShareShare
ReportReport
Posted on by 28,983 Moderator

Hi,

Can anybody please tell how to hide/show header field using javascript in CRM 2013 ?

I have used below code 

//True for Hide , False for Show

Xrm.Page.getControl("header_new_account").setVisible(false);

Hide is able to hide the label only but block is visible. PFB screenshot for the same.

5040.Capture.PNG

Also, below JS code to Show the field is not working.

Xrm.Page.getControl("header_new_account").setVisible(false);

Please help !

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ashlega Profile Picture
    34,477 on at

    Hi Bipin,

     not sure if it was a copy-paste error, but your JS code for showing the field should be using "true" as a parameter:

    Xrm.Page.getControl("header_new_account").setVisible(true);

     As for the block.. Did you try hiding the field in the form designer (try to reverse the logic - hide by default, then use the script to show if needed. Might or might not help, but I would try)

    UPDATE: After a bit of testing, it seems that setVisible(true) does not work. At least it does not seem to work if the field is hidden by default. I'm guessing the answer is - if you need this kind of logic, don't put that field in the header

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Hi

    It would hide the control.

    I do not think it would remove the block, altogether

    For BPF

    Use

    header_process_<attribute name>.

    header_process_new_account

    Xrm.Page.getControl("header_process_new_account").setVisible(false);

    Please refer:

    [View:https://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_setVisible:750:50]

  • Bipin D365 Profile Picture
    28,983 Moderator on at

    Yes it was copy paste mistake..I am using correct value only. We tried reverse logic as well..

    Now i am using below code to Show/Hide

    document.getElementById("header_new_account_d").parentElement.style.display = 'block';

    document.getElementById("header_new_account_c").parentElement.style.display = 'block';

    document.getElementById("header_new_account").parentElement.style.display = 'block';

    document.getElementById("header_new_account_d").parentElement.style.display = 'none';

    document.getElementById("header_new_account_c").parentElement.style.display = 'none';

    document.getElementById("header_new_account").parentElement.style.display = 'none';

    I know this is unsupported. But the above code is not showing field label.

    the label name Account is not visible.

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