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)

visible true/false tabs

(0) ShareShare
ReportReport
Posted on by

Hi, I need help with an specific requirement of my client, maybe someone would can help me.

My client wants a form with a dropdown where he can choose the quantity of floors a building has, and the tabs (where are the text fields with the information of each floor) are repeated for each floor. For example, if I choose "3" in the dropdown, the tab with the text field "kitchen" needs to apears 3 times in the form.

I know that it is posible to do with CRM configurations but the client wants it with javascript, my code is this:

function MostrarSecciones(){

var numnivel = window.parent.Xrm.Page.getAttribute("bln_nrodeniveles").getValue();

switch(numnivel)
{
case 1:
Xrm.Page.ui.tabs.get("DN1").setVisible(true);
case 2:
Xrm.Page.ui.tabs.get("DN1").setVisible(true);
Xrm.Page.ui.tabs.get("DN2").setVisible(true);
case 3:
Xrm.Page.ui.tabs.get("DN1").setVisible(true);
Xrm.Page.ui.tabs.get("DN2").setVisible(true);
Xrm.Page.ui.tabs.get("DN3").setVisible(true);
case 4:
Xrm.Page.ui.tabs.get("DN1").setVisible(true);
Xrm.Page.ui.tabs.get("DN2").setVisible(true);
Xrm.Page.ui.tabs.get("DN3").setVisible(true);
Xrm.Page.ui.tabs.get("DN4").setVisible(true);
case 5:
Xrm.Page.ui.tabs.get("DN1").setVisible(true);
Xrm.Page.ui.tabs.get("DN2").setVisible(true);
Xrm.Page.ui.tabs.get("DN3").setVisible(true);
Xrm.Page.ui.tabs.get("DN4").setVisible(true);
Xrm.Page.ui.tabs.get("DN5").setVisible(true);
case 6:
Xrm.Page.ui.tabs.get("DN1").setVisible(true);
Xrm.Page.ui.tabs.get("DN2").setVisible(true);
Xrm.Page.ui.tabs.get("DN3").setVisible(true);
Xrm.Page.ui.tabs.get("DN4").setVisible(true);
Xrm.Page.ui.tabs.get("DN5").setVisible(true);
Xrm.Page.ui.tabs.get("DN6").setVisible(true);
}
}

but it is not working and I don't know if the problem is some error in the code or that is not possible to do this in this way, somebody has the solution?

Note: I call my tabs "DN" and the number correspondt. 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    M I Mostafa Profile Picture
    4,257 on at

    Hi Diana,

    I would suggest that you don't use JavaScript for this but rather consider using Business Rules to achieve this. You could have a Business Rule that starts with a condition depending on the value in the drop down and then show/hide as required. You could also do this for a whole section. You can have a look at this post for full details:

    dynamicscrmpros.com/hiding-section-fields-microsoft-dynamics-crm-2013-using-business-rules

    Hope this helps! Please click "yes" if you found this response helpful.

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

    Hello,

    1. Change line

    var numnivel = window.parent.Xrm.Page.getAttribute("bln_nrodeniveles").getValue();

    to line

    var numnivel = Xrm.Page.getAttribute("bln_nrodeniveles").getValue();

    2. You can replace your switch with following simple lines:

    Xrm.Page.ui.tabs.get("DN1").setVisible(numnivel >= 1);

    Xrm.Page.ui.tabs.get("DN2").setVisible(numnivel >= 2);

    Xrm.Page.ui.tabs.get("DN3").setVisible(numnivel >= 3);

    Xrm.Page.ui.tabs.get("DN4").setVisible(numnivel >= 4);

    Xrm.Page.ui.tabs.get("DN5").setVisible(numnivel >= 5);

    Xrm.Page.ui.tabs.get("DN6").setVisible(numnivel >= 6);

    3. Please confirm that your optionset has not only labels from 1 to 6 but values as well are listed from 1 to 6.

  • Verified answer
    Community Member Profile Picture
    on at

    Never go with this...

    To make the user input scalable, why don't you create a 1:N relationship so that it is more flexible and you can easily expand the input form (in case they want more fields).

    Making the subgrid editable will simplify the input process as well.

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