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

Announcements

News and Announcements icon
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 ?
I have the same question (0)
  • Suggested answer
    chris xu Profile Picture
    on at

    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

  • Pat C Profile Picture
    5 on at

    Hi Sahara

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

    Regards

    Paddy C

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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.

  • Arun Vinoth Profile Picture
    11,615 Moderator on at

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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 119 Super User 2026 Season 2

#2
Syed Aqib Raza Profile Picture

Syed Aqib Raza 72

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 66 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans