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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

how to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box in crm on premise ?

(0) ShareShare
ReportReport
Posted on by 670

i want to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box ?

mandatory.JPG

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at
    RE: how to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box in crm on premise ?

    Hi Sabih,

    You can use Business Rule Script to make field mandatory no other field change.

    Thanks,

    Shahbaaz

  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at
    RE: how to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box in crm on premise ?

    Hi Sabih,

    You can use Business Rule  or JavaScript to make field mandatory no other field change.

    Thanks,

    Shahbaaz

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: how to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box in crm on premise ?

    Hi,

    you can use business rule to achieve this

    community.dynamics.com/.../using-business-rules-to-hide-fields-and-make-them-required-as-needed

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at
    RE: how to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box in crm on premise ?

    You can do this using JavaScript or Business Rule.

    On the change event of the checkbox, set the Requirement Level of the two fields to required.

    Using JavaScript:

    function chkAMC_OnChange()

    {

      var isChecked = Xrm.Page.getAttribute("new_chkAMC").getValue();

      if (isChecked)

      {

         Xrm.Page.getAttribute("new_fromDate").setRequiredLevel("required");

         Xrm.Page.getAttribute("new_toDate").setRequiredLevel("required");

      }

      else

      {

         Xrm.Page.getAttribute("new_fromDate").setRequiredLevel("none");

         Xrm.Page.getAttribute("new_toDate").setRequiredLevel("none");

      }

    }

    JavaScript file should be created and uploaded to server as web resource.

    Add Web Resource to form, and add the onChange event to the checkbox control and enter the function name where required.

    Logic should be similar to above using Business Rules.

    Hope this helps.

  • account payable Profile Picture
    670 on at
    RE: how to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box in crm on premise ?

    checkbox of AMC using from option set so how to write javascript code

    srvcordrtype.JPG

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: how to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box in crm on premise ?

    Hi,

    for all the checkboxes, are they built using html code?

    if yes, follow below post

    butenko.pro/.../howto-htmljs-webresources

  • account payable Profile Picture
    670 on at
    RE: how to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box in crm on premise ?

    Hi Wei Jie Fun,

    yes all the checkbox are built using html

    HTMLPASSWEBRESOURCE.JPG

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: how to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box in crm on premise ?

    Hi,

    then refer to the link, on that particular checkbox checked, trigger the JS

    function myFunction()

    {

      if(htmlcheckbox== true)

        window.parent.Xrm.Page.getAttribute("fieldschema").setRequiredLevel("required");

    else

    window.parent.Xrm.Page.getAttribute("fieldschema").setRequiredLevel("none");

    }

  • Suggested answer
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at
    RE: how to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box in crm on premise ?

    Take the help of the following code. Hope it helps:

    $(document).ready(function() {

    $("#chekcboxControlId").change(function() {
    if(this.checked) {
    window.parent.Xrm.Page.getAttribute("fieldschema").setRequiredLevel("required");
    }
    else
    {
    window.parent.Xrm.Page.getAttribute("fieldschema").setRequiredLevel("none");
    }
    });

    });

    If my answer helped to resolve your issue, kindly verify it by clicking 'Yes'. It would be helpful to the other community members seeking to resolve a similar issue.


    Cheers
    Arpit
    https://arpitmscrmhunt.blogspot.in

     

     
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: how to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box in crm on premise ?

    Hi Sabih,

    Modified Aric's code , accessing from web resource to form using window.parent. 

    Just replace the field name and trigger in on change of checkbox which you want.

            function chkAMC_OnChange() {
                var isChecked = Xrm.Page.getAttribute("new_chkAMC").getValue();
                if (isChecked) {
                    window.parent.Xrm.Page.getAttribute("new_fromDate").setRequiredLevel("required");
                    window.parent.Xrm.Page.getAttribute("new_toDate").setRequiredLevel("required");
                }
                else {
                    window.parent.Xrm.Page.getAttribute("new_fromDate").setRequiredLevel("none");
                    window.parent.Xrm.Page.getAttribute("new_toDate").setRequiredLevel("none");
                }
            }


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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans