When creating Window Navigation Rules (WNRs, or simply Rules) for Unified Service Desk (USD), have you ever thought to yourself, “I wish I didn’t need so many of these darn things…?” If you’re configuring USD to handle navigations involving dozens of entities, then you probably have! In small handfuls, WNRs can already be tricky enough to manage, so keeping them scalable as more entities join the configuration can pose a challenge. In this blog, we’ll explore a technique for writing fewer Rules to keep your configuration manageable.
If you’re writing Rules the way most of us are taught, then you’re probably writing them in a completely explicit fashion. Imagine that you have three Controls for three Entities: X, Y, and Z. You would like to always load these Entities in their respective Controls within USD Sessions. You also have a Global Search Control that should always create USD Sessions when accessing these Entities. To accomplish all of this, you might define a very explicit set of Rules that looks something like this:
- When Global Search navigates to Entity X, create a Session and route it to Control X.
- When Global Search navigates to Entity Y, create a Session and route it to Control Y.
- When Global Search navigates to Entity Z, create a Session and route it to Control Z.
- When Control X navigates to Entity Y, route it to Control Y.
- When Control X navigates to Entity Z, route it to Control Z.
- When Control Y navigates to Entity X, route it to Control X.
- When Control Y navigates to Entity Z, route it to Control Z.
- When Control Z navigates to Entity X, route it to Control X.
- When Control Z navigates to Entity Y, route it to Control Y.
WHEW! That’s already a lot of Rules, but for so few Entities! If you have dozens of entities that require USD navigation handling, then your number of explicit Rules can grow exponentially.
To write fewer Rules and maintain this functionality, go implicit by writing Rules that handle multiple Entities or Controls. This technique involves leaving certain WNR fields blank, and triggering Rule re-evaluation when appropriate:
- When you aren’t starting Sessions, omit the “origin of navigation” control by leaving the From field blank. It’s optional!
- When you are starting Sessions, omit the Entity / URL (which are also optional!) and trigger WNR reevaluation using Global Manager as the destination control, or “Target Tab.”
This little-known technique is based on a cool trick that’s documented in the USD Developer Guide. Check out what the guide says about Window Navigation Rules, and how to use the “Target Tab” field:
When this rule matches, this is where the window will be directed. If the target tab (hosted control) is a dynamic control, it will automatically be loaded and the window will be directed to it. If this field is set to the Global Manager and the Action is Create Session, the system will re-evaluate the rules to determine the actual location of the window in the tabs. This is useful to avoid creating a Create Session rule for every route type that might pop up from a particular window. If you leave the Target Tab field empty, an entity search is performed using first entity search matching the type of entity from the popup.
Applying this technique to our example scenario above, we can provide the same functionality with a much smaller set of Rules, like this:
- When Global Search navigates to any Entity, create a Session and route it to Global Manager.
- When any Control navigates to Entity X, route it to Control X.
- When any Control navigates to Entity Y, route it to Control Y.
- When any Control navigates to Entity Z, route it to Control Z.
Voila! This technique reduced the number of Rules from nine to four! This may not seem like a lot, but this was a simplified example. Imagine having 20 entities in the mix instead. In an example like that, we would begin with 400 explicit Rules, and end with only 21 Rules total after applying the technique. That’s enormous! Trust me, I ran the numbers.
Just make sure that any Create Session Rules have a lower Order number than the Rules that route specific Entities to specific Controls upon reevaluation. Also, keep in mind that you may need two Rules for certain routing logic if you need to handle the two most common navigation types: Popup and In Place.
To get all of the latest and greatest tips for Dynamics 365, make sure to subscribe to our daily blog!
Happy Dynamics 365’ing!