The current functionality of the solution is limited to:
- Each rule is governed by a single IF/ELSE condition.
- The rule works with Entity forms and Web form steps.
- Each rule can have unlimited number of actions. Actions include Show/Hide fields. Disable/Enable Fields, Make fields Required/Not Required, Set Field Value, Prevent Past Date and Prevent Future Date (for Datetime fields), Show/Hide Sections, Show/Hide Tabs.
- A rule will parse the XML of the related form or tab and suggest the fields/sections/tabs to be used in the rule logic.
- For some of the field types (Option sets and two option sets), a suggested value table shows up for ease of use. So instead of figuring out the integer value of an option set field, they will be listed for the user to select from.
- The ability to use “In” and “Not In” Operators. For example you can say if an option set value is in “2^3^4” which means if the option set is either of these 3 values, then the condition will hold true.
- You can see the generated Java script directly in a special tab.
- The Generated Java script for all the rules gets injected into the Entity form or web form step Custom Java script field and it is decorated with special comments to make it clear that this is generated by the solution and not by hand.
- When a rule is deleted or drafted, its logic gets removed automatically from the corresponding entity form or web form step.
- Basic error handling is added so that when the operands has the wrong value format, an error will show up to tell the user to fix it.
Here is a quick video showing the installation steps:
Here is a simple rule creation demo that shows/hides a tab based on a two option set value:
Another demo of multi action rule, where the Job Title field is shown and becomes required if the Company Name field is populated:
Another demo of how an option set is used in a rule. How error handling works if the operand value is of wrong format.
And finally, the “In” Operator is one of the advanced operators. Here is an example of how we can populate a field if the condition falls into one of a predetermined list of values:
Of course, there are many other possible operations features that you want to check out if you install the solution. Manipulating section visibility, field states (enabled and disabled) and many more.
Many will notice that we can only have one condition in a single rule for now and I’m currently thinking on the best way to associate other conditions to a rule with either AND or OR logical operators between them, similar to how Dynamics 365 Business Rules behave.
To be fair, the best solution for this problem is not my proposed solution but is to make the Business rules that currently exist for Dynamics forms work on the Portal Forms as well, I can say that this solution needs to be done by Microsoft itself as there no much visibility on the Business Rules engine for us,developers. Based on my knowledge, the business rules in Dynamics seem to be built using the Windows Workflow Foundation (from looking at their XAML).
In summary, the problem I’m trying to solve is reducing the need for code further, similar to how Business Rules reduced the need for client side scripting on the Dynamics 365 side. If code is still needed, then my solution and custom code can still live together.
Please refer to my repository on Github for installation steps. Feedback is really appreciated.
NOTE: For the Java script functions that I call in the back-end, I use this existing library on GitHub developed by Aung Khaing .
Update October 16, 2019