web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

hide multiple fields in CRM using wildcard for fieldnames

(0) ShareShare
ReportReport
Posted on by 1,577

Hello,

I want to hide several fields via an onchange event for a yes/no field on a CRM form.

The field names all have the same prefix so is there any way I can use a wildcard to set the visibility of all the fields based on their fieldname.

So instead of individually:

Xrm.Page.ui.controls.get("new_sg2_text1").setVisible(true);
Xrm.Page.ui.controls.get("new_sg2_text2").setVisible(true);
Xrm.Page.ui.controls.get("new_sg2_text3").setVisible(true);

I would like something like

Xrm.Page.ui.controls.get("new_sg2_%").setVisible(true);

Many thanks for any suggestions.

- Seamus

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gupta.ambar2009@gmail.com Profile Picture
    797 on at

    Hello ,

    Use below .

    entityObject.attributes.forEach(function (control, index) {
    if (attributeEnableList.indexOf(control.getName()) == -1 && !control.getName().toString().includes(".")) {
    entityObject.attributes.getByName(control.getName()).controls.getByName(control.getName()).setDisabled(true);
    }
    });

    you could change the check condition as per your need .

  • Seamus Profile Picture
    1,577 on at

    Thanks Ambar, - sorry for being slow to grasp this but (a) how I would I amend your code to use the wildcard "new_sg2_" and (b) is setDisabled the same as setVisible? Many thanks again.

  • Verified answer
    gupta.ambar2009@gmail.com Profile Picture
    797 on at

    its different

    in place of setdisable write setvisible ,as below

    entityObject.attributes.forEach(function (control, index) {

    if (attributeEnableList.indexOf(control.getName()) == -1 && !control.getName().toString().includes(".")) {

    entityObject.attributes.getByName(control.getName()).controls.getByName(control.getName()).setVisible(false);

    }

    });

    if its helped then please mark as resolved to help it other

  • Seamus Profile Picture
    1,577 on at

    Thanks Ambar!

  • Verified answer
    naresh babu Profile Picture
    425 on at

    You can use Business rules.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans