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 :
Microsoft Dynamics CRM (Archived)

Business Rule cannot detect the value set by JS

(1) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    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

  • ashlega Profile Picture
    34,477 on at

    I would try using

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

    in your javascript right after you have set the checkbox

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans