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

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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans