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 :
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

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

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans