Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Suggested answer

Hide few fields based on some condition

(0) ShareShare
ReportReport
Posted on by 5

Hello Experts,

I need your help in one of my issue. I want to hide few fields based on some condition. For e.g if Field A has 1 value than Field B should show otherwise not.

I tried but didn't work. Could any one please suggest how to achieve.

Thanks in advance.

Ravi 

  • FidelMartin Profile Picture
    FidelMartin 128 on at
    Hide few fields based on some condition

    Follow the below steps to hide/show the tab in the form.

    Step 1: First, we will create one JS file and write the code as below.

    new_type: Is a Logical name of field.

    type_contact: It’s a unique name of a tab which we want to hide or show.

    function hideShowTab() {
    var type = Xrm.Page.getAttribute("new_type").getValue();
    if (type != “”) {
    window.parent.Xrm.Page.ui.tabs.get("type_contact").setVisible(true);
    }
    else {
    window.parent.Xrm.Page.ui.tabs.get("type_contact").setVisible(false);
    }
    }

    ➢ So here we create a function hideShowTab, which we will call on loading of the form.

    If you want to know in deatils please refer this blog.

  • cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Hide few fields based on some condition

    Hi Ravi,

    You can use JavaScript to hide one field.

    Here are steps.

    1.write custom JavaScript code.

    5415.png

    2. Add your JavaScript code in a Script web resource.

    3678.png

    3. Associate Script web resource to a form.

    (1) In the Main form of Opportunity, click Form Properties.

    1121.png

    (2) Click Add button to lookup record dialog box, search and select file you created.

    0572.png

    (3) To the Handler Properties dialog box.

    3652.png

    (4) Click Add button.

    5187.png

    4. Test your JavaScript code.

    3362.png

    When the type field is filled with data, the End customer field will not be shown in the form.

    6765.png

    Regards,

    Clofly

  • Ravi_2020 Profile Picture
    Ravi_2020 5 on at
    RE: Hide few fields based on some condition

    No it is not working as the field "Type" is fetching data from another entity via javascript. When I change the acccount field ( lookup) on opportunity form, it trigger javascript which fetches data for "Type" field  from account form. And as soon as type field is filled with data, it should trigger business rule for field "End customer" to be invisible from the form. Business rule is working fine for any simple text field but not for this "type" field.

    Also "Type" field data type optionset. if that helps.

  • Suggested answer
    dian74 Profile Picture
    dian74 2,475 Most Valuable Professional on at
    RE: Hide few fields based on some condition

    Hi Ravi,

    You can use business rules for that. Go to https://make.powerapps.com/, (make sure you're logged into the correct environment which is visible on your top right; click on the environment name to change it) Then click 'Entities' under the 'Data' heading. Open the entity you want to change, then click 'Business Rules'. Here is where you can create the business rules. Click "Add business rule' on the ribbon. You'll see the 'New Condition' is already populated. Click on it and you'll see the properties window open on the right hand side. Here is where you put your condition. (If Field A has value 1) In my example my condition is if Task Target equals Max Size) make sure you click appy after you entered the condition.

    BR_2D00_Step1.PNG

    Now click on the Components tab (on the properties window you just used) and drag the 'Set Visibility' step on the screen as shown in the screenshot. Click on the "Set Visibility" action. The properties screen opens again and you can enter your logic here. In my example Im hiding the completion date field if my condition is met (Purple checkmark). You can drag a second "set visibility" action to the screen under the X of the condition, this will represent what will happen if the condition isn't met. 

    BR_2D00_Step2.PNG

    Please mark this answer as verified if 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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans