Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

visible true/false tabs

Posted on by Microsoft Employee

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

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: visible true/false tabs

    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.

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: visible true/false tabs

    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.

  • Suggested answer
    M I Mostafa Profile Picture
    M I Mostafa 4,257 on at
    RE: visible true/false tabs

    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.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans