Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

How to setRequired specific control or attribute if it's multiple on form

(0) ShareShare
ReportReport
Posted on by 645

My mission is to check if a control is visible and if it is then to set it as required. On my form I have the same field twice (in different sections) so to check my control visibility I use this code:

 if(Xrm.Page.ui.tabs.get("tab1").sections.get("section").controls.get("attrname").getVisible()) -works
{
           Xrm.Page.ui.tabs.get("tab1").sections.get("section").controls.get("attrname").setRequiredLevel("required"); - doesn't work - error
           Xrm.Page.ui.tabs.get("tab1").sections.get("section").controls.get("attrname").getAttribute("attrname").setRequiredLevel("required");- doesn't work - error
    }

I have a prob in setting the specific attr/control as required, is it possible ?
  • Arun Vinoth Profile Picture
    11,615 Moderator on at
    RE: How to setRequired specific control or attribute if it's multiple on form

    Cross-post from SO thread - stackoverflow.com/.../7920473

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: How to setRequired specific control or attribute if it's multiple on form

    Hello,

    In your previous thread we have already started discussion on your current question - community.dynamics.com/.../how-to-get-specific-attribute-from-a-specific-tab-and-section

    I replied that you can't set required level for a specific control - it's attribute's property so it will set requirement level of all of controls related to particular attribute.

  • Pat C Profile Picture
    5 on at
    RE: How to setRequired specific control or attribute if it's multiple on form

    Hi Sahara

    For first instance of your field on your form use "attrname" for second instance "attrname1".

    Regards

    Paddy C

  • Suggested answer
    chris xu Profile Picture
    on at
    RE: How to setRequired specific control or attribute if it's multiple on form

    Hi Sahara,

    • what's the error you encounter with your current script?
    • Have you tried with this script to Set the required level: Xrm.Page.getAttribute("x").setRequiredLevel("required");
    • In addition, which page event are you involving this logic function in? Onload, OnChange?
    • How are you maintaining the visibility of the fields, please try to involve the required level setting together with visibility changing if applicable.

    Regards,

    Chris X

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 > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans