D365: JavaScript and Business Rule on the same field

Recently, on change of value of a field, we had business rule earlier and then we decided to perform the same using JavaScript to avoid hard coding of value in Business rule. The logic was to set value of 2 other fields on the form based on the value selected.

The logic was working fine on DEV as we had deactivated the business rule. However, after deploying to TEST and UAT, it stopped working.

We verified that the JavaScript event handler was enabled for the OnChange event of that field.

bb

While debugging the code as well using browser console, we checked that the break point was hitting the code block where we were setting the value of 2 other fields.

aa

After struggling for few minutes, it came to our mind that Business rule was also written which should have been deactivated.

cc

The business rule was basically clearing the values of the 2 fields if the selected value of field was not in the condition anywhere.

dd

After deactivating the business rule, closing the form, opening it again when we tested it, it worked.

So, if we have JavaScript and Business Rule written on the same field, then the order of execution is first JavaScript then Business Rule for which even if the values of the 2 fields were set using JavaScript were getting cleared by the Business Rule.

Hope it helps !!

Advertisements

3 thoughts on “D365: JavaScript and Business Rule on the same field

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.