web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    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 .

  • 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.

  • 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!

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

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
UllrSki Profile Picture

UllrSki 2

#3
SC-08081331-0 Profile Picture

SC-08081331-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans