Skip to main content

Notifications

Announcements

No record found.

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

  • Verified answer
    naresh babu Profile Picture
    425 on at
    RE: hide multiple fields in CRM using wildcard for fieldnames

    You can use Business rules.

  • Seamus Profile Picture
    1,577 on at
    RE: hide multiple fields in CRM using wildcard for fieldnames

    Thanks Ambar!

  • Verified answer
    gupta.ambar2009@gmail.com Profile Picture
    797 on at
    RE: hide multiple fields in CRM using wildcard for fieldnames

    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
    RE: hide multiple fields in CRM using wildcard for fieldnames

    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.

  • Suggested answer
    gupta.ambar2009@gmail.com Profile Picture
    797 on at
    RE: hide multiple fields in CRM using wildcard for fieldnames

    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 .

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans