Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Business Rule cannot detect the value set by JS

Posted on by Microsoft Employee

Hello experts, recently I encountered the following problem:

Context: There are 4 fields in the contact form: birthday, child (checkbox), email and telephone number. So in general, the fields email and telephone are mandatory; but since if it is a child, these information might not be necessary, we set up a business rule which basically says if the checkbox is checked, these two fields are not mandatory anymore.

On the other hand, in order to facilitate the sales process, we use JS to calculate the age of the child and checked the checkbox automatically if age is less than 18. For example: when I entered 02/08/2016, the age field will be filled with 1, and the check box will be checked.

The problem is when I manually checked the checkbox, the business rule will work and hence the fields email and telephone are no more mandatory, but when I entered first the birth date, and JS automatically checked the checkbox, the business rule doesn't work. So why the business rule didn't take the JS results into account ?


Thank you all for your help and have a nice day.

Cheers,

Yi

*This post is locked for comments

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: Business Rule cannot detect the value set by JS

    I would try using

    Xrm.Page.getAttribute("CHECKBOXATTRIBUTE_NAME).fireOnChange()

    in your javascript right after you have set the checkbox

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Business Rule cannot detect the value set by JS

    Hi,

    here is your answer: community.dynamics.com/.../221799

    You can also replace your business rules by a Javascript function which verifies the above condition. Simply call this function onLoad of the form and onChange of this checkbox.

    Best

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans