Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

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

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
    Arun Vinoth 11,613 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
    a33ik 84,323 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
    Pat C 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
    chris xu 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans