MSBA-271 · Lesson 12 of 12 · 19 min
Case study: a custom map control
▶ Video coming soon A video version of this lesson is on the way.
The facilities program's most requested improvement had been on Bronwyn's list since MSBA-250: picking a room by looking at a floor plan instead of scrolling a lookup list of codes such as SCI-2-114. Dispatchers knew rooms by where they were, not by their codes, and new staff took weeks to learn them. This final case study follows the design of RoomPicker, a code component that shows a building floor plan, lets the user choose a room on it and writes the matching location to the Location lookup on the work order. At the time of writing it was a prototype in Wiremu Dev, with a design review complete and a plan for release. Nothing had reached test or production.
The requirement
Signe insisted on writing the requirement before any code. It was short, and every line came from a conversation with someone who would use or support the control.
| Requirement | Source |
|---|---|
| Show the floor plan for the selected building and floor, with rooms outlined | Bronwyn, dispatch |
| Choose a room by clicking or tapping it, and write the matching location to the Location lookup on the form | Bronwyn, dispatch |
| Show each room's code and name, and mark rooms that are out of service | Arlo Hemsworth, maintenance |
| Work fully by keyboard and screen reader, with an equally good list alternative | Ingrith Varsamis, accessibility services |
| Work on the Work Order form in Facilities Hub, and write nothing but the lookup so reports stay consistent | Kwabena, reporting |
| Update floor plans without a code release when buildings are renovated | Delphine Okoro-Vance, facilities business owner |
| Release through the Lumenvale Facilities Controls solution with tests and version checks | Rupert, release management |
The list ruled things out as well as in. It did not ask for routing, live occupancy or a campus map; those were separate ideas for later, and Signe kept them out so the first version could be finished. Octavia approved the scope with one condition: no new licenses and no external mapping service, which meant the floor plans had to be Lumenvale's own drawings.
Choosing the kind of solution
The team considered four options before choosing a code component. The table records why each was or was not chosen, which became part of the design document.
| Option | Verdict | Reason |
|---|---|---|
| Improve the lookup with filtering and views | Done as well, not enough alone | Helps users who know codes; does not help users who know places |
| A canvas custom page opened from the form | Rejected | An extra dialog for every pick; the form already has the room field |
| A code app for room picking | Rejected | Picking is one step in larger forms, not a whole app |
| A React field component bound to the Location lookup | Chosen | Replaces the control where the choice happens, in every form that uses the field |
The decision used everything in this course. Lesson 5's distinction between field and dataset components pointed to a field component, since one value, the Location lookup, was being chosen. Lesson 5's comparison of standard and React components pointed to React with the platform's Fluent library, for a smaller bundle and consistent styling. Lessons 8 and 9 explained why a code app was the wrong scope, and lesson 4's command techniques were kept for a separate "Show on floor plan" command on the Room view, which would open the same component in a custom page later.
Data: floor plans as records
Delphine's requirement to update plans without a release decided the data design. Each floor plan became a row in a new Floor Plan table, with a lookup to Building, a floor number and a file column holding an SVG drawing exported from the campus drawing system. Each room in the SVG carried an id attribute equal to the room's code, which was the link between drawing and data. The Room table, shared through Lumenvale Core, already had building, floor and code columns, and gained an out-of-service column; the Location table from MSBA-251 linked each work order location to its room, so the component could find the Location row for the room a user chose.
Using SVG for the plans had several advantages. SVG scales cleanly at any zoom, which matters for accessibility and for the counter tablets; its elements can be styled with CSS, so selected and out-of-service rooms can be shown without changing the drawing; and its elements can carry accessible names. The campus drawing office agreed to export each floor with room ids, and Delphine's team would upload new files when buildings changed.
Manifest and properties
The component's manifest declared one bound property and a small set of inputs. The bound property was the Location lookup. Lookups as bound properties are supported for field components in model-driven apps, with the value given as an array of entity references, the same shape as in the client API in lesson 1. Inputs controlled the building and floor columns to read from the form, and whether to start with the plan or the list.
<control namespace="Lumenvale" constructor="RoomPicker" version="0.3.0"
display-name-key="RoomPicker_Display" description-key="RoomPicker_Desc"
control-type="virtual">
<property name="location" display-name-key="Location" of-type="Lookup.Simple" usage="bound" required="true" />
<property name="building" display-name-key="Building" of-type="Lookup.Simple" usage="input" required="false" />
<property name="startView" display-name-key="StartView" of-type="Enum" usage="input" default-value="plan">
<value name="plan" display-name-key="Plan">plan</value>
<value name="list" display-name-key="List">list</value>
</property>
<resources>
<code path="index.ts" order="1" />
<platform-library name="React" version="16.14.0" />
<platform-library name="Fluent" version="9.46.2" />
</resources>
<feature-usage>
<uses-feature name="WebAPI" required="true" />
</feature-usage>
</control>The component used context.webAPI to read the floor plan row and the rooms on that floor, rather than calling Xrm directly, because the context object is the supported route in a component and works in each host that provides it. The uses-feature element declared that dependency, so a host that does not provide WebAPI would fail clearly rather than mysteriously, as lesson 5 explained. The prototype did not yet work in canvas apps, which was acceptable because the requirement named only the model-driven forms.
Behavior and state
Inside, RoomPicker was a React component with a small amount of state: the building and floor being viewed, the list of rooms on that floor, the plan's SVG text, and the selected room. When the user chose a room, the component stored it and called notifyOutputChanged, and getOutputs returned the new lookup value, following lesson 6's rule that undefined means no change and null clears the value. When the form changed the room by another route, such as a script or a business rule, updateView received the new value and the component highlighted it.
Three design decisions came from earlier lessons. Rooms on a floor were loaded with one Web API call selecting only the columns needed, and cached for the session, following lesson 9's performance practices. Requests for floor plans tracked the latest request and ignored stale responses, the race condition fix from lesson 11, because users often clicked quickly through floors. And the SVG was sanitized before being inserted into the page, removing scripts and event handler attributes, because any file uploaded to a table could in principle contain them; the component treated the drawing as untrusted data even though it came from Lumenvale's own drawing office.
Accessibility by design
Ingrith joined the design from the first sketch rather than reviewing at the end, which she said was the single biggest improvement since lesson 10. A floor plan is a picture, and pictures are hard to make accessible, so the design gave every user two equal routes to the same choice: the plan and a list. The list was a real Fluent list of rooms, grouped by wing, with codes, names and out-of-service status, fully usable by keyboard and screen reader. The plan was enhanced for those who could use it, and both stayed in step: choosing in one highlighted the choice in the other.
| Concern | Design |
|---|---|
| Keyboard access to rooms on the plan | Rooms are focusable in a logical order; arrow keys move between neighboring rooms; Enter chooses |
| Screen reader names | Each room outline has an accessible name such as "SCI-2-114, Chemistry teaching lab, available" |
| Not color alone | Selected rooms have a thick outline and a check icon; out-of-service rooms are hatched and labeled |
| Zoom and reflow | The plan scales with the container; at narrow widths the list appears above the plan |
| Announcements | A polite live region announces the chosen room |
| Equal alternative | The list offers everything the plan does, and can be the starting view |
Testing and release plan
The plan followed lesson 7. Logic that did not need the framework, such as mapping SVG ids to rooms, ordering rooms for keyboard movement and sanitizing drawings, lived in plain modules with unit tests. The harness covered drawing at different sizes and the empty, disabled and out-of-service states. Playwright tests in a test environment would cover choosing a room on the Work Order form by mouse and by keyboard, and confirm that the lookup saved. Accessibility testing included the checklist, a screen reader pass and a session with the two staff members who had tested the loans app.
RoomPicker would be added to the Lumenvale Facilities Controls solution beside RoomCapacity, built in Release configuration by GitHub Actions with the manifest version check, and released through the facilities pipelines to Facilities Test and then Facilities. Solution checker and npm audit would run in the build. Rupert asked for one more thing: the standard lookup control would remain available on each form, so that if RoomPicker had a problem, a maker could switch the field back to the standard control in minutes without a release.
The design review
Before the prototype went further, Signe held a design review with everyone whose requirement was on the list. The review was not a demonstration; it was a structured check of the design against requirements, risks and support. Its record became the template for later reviews.
| Question asked in the review | Outcome |
|---|---|
| Does the design meet every requirement? | Yes, except plan updates for renovated floors, which need the drawing office's export to keep room ids; agreed with the office |
| What happens when a floor has no plan yet? | The component shows the list only, with a message, so it is never a dead end |
| What could go wrong in production, and how would we know? | Errors and load times logged to Application Insights; a quick fallback to the standard lookup |
| Who supports it? | Wiremu, with Signe as reviewer; documentation in the repository |
| Will reports still be right? | Yes; the component writes only the Location lookup, as the standard control does |
| Is any data at risk? | No new data access beyond rooms and plans; drawings sanitized; no personal data |
| Is it accessible? | Designed with accessibility services; full review before release |
Two changes came out of the review. Bronwyn asked for the most recently used rooms at the top of the list, which was simple and useful. And Maribeth pointed out that registrar exam bookings sometimes needed several rooms, which a single-value field component could not do; the team recorded it as a separate need, possibly for a dataset component later, rather than stretching RoomPicker beyond its design.
Worked problem
Choosing what to say no to
During the review, a manager asks whether RoomPicker could also show live occupancy from the building sensors. What should Signe answer?
Show solution
- Check the requirement list: live occupancy is not on it.
- Consider the cost: a new data source, new privacy and security questions, and a dependency on the sensor system's availability.
- Consider the risk to the current scope: adding it would delay a control that dispatch needs now.
- Record it as a candidate for a later version, with an owner to explore the sensor data.
Answer: Signe thanked the manager, recorded live occupancy as a later idea with Delphine as owner, and kept RoomPicker's first version to the agreed scope.
What the course has built
RoomPicker drew on almost every lesson: the client API and its lookups from lesson 1, form events from lesson 2, commands from lessons 3 and 4, component design from lessons 5 and 6, testing and packaging from lesson 7, the comparison with code apps from lessons 8 and 9, accessibility from lesson 10 and debugging from lesson 11. Wiremu, who had started the term able to write a form script, had built and released RoomCapacity, built the athletics loans app and designed RoomPicker. Signe's summary of the course was simple: choose the smallest piece of custom code that meets the need, build it like any professional software, and make it work for everyone.
Common mistakes
MistakeStarting with code before writing the requirement.
InsteadWrite down who needs what, and what is out of scope, first.
MistakeTreating the plan as the only way to choose.
InsteadOffer an equal, accessible alternative such as a list.
MistakeHard-coding floor plans in the component.
InsteadStore them as data so that they can change without a release.
MistakeInserting uploaded drawings into the page as they are.
InsteadSanitize them, treating files as untrusted data.
MistakeRemoving the standard control when adding a custom one.
InsteadKeep a quick fallback to the standard control.
Summary and key terms
- RoomPicker is a React field component bound to the Location lookup, designed to choose rooms on a floor plan; it is a prototype with a completed design review.
- Requirements came from users and support staff and set clear limits on scope.
- Floor plans are stored as SVG files in a table, linked to rooms by id, so they change without a release.
- The component reads data through context.webAPI, ignores stale responses and sanitizes drawings.
- Accessibility was designed in, with a list that is an equal alternative to the plan.
- Testing and release follow the same solution project, pipeline and fallback practices as RoomCapacity.
- RoomPicker
- Lumenvale's prototype code component for choosing a room on a floor plan.
- SVG
- Scalable Vector Graphics, a drawing format that scales cleanly and can be styled and labeled.
- Sanitize
- Remove potentially harmful content, such as scripts, from data before using it.
- Equal alternative
- A second way to complete a task that offers everything the first does.
- Design review
- A structured check of a design against requirements, risks and support before building further.
- Fallback
- A quick way to return to a known working state, such as the standard control.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Why was RoomPicker built as a field component rather than a code app?
Show answer
Choosing a room is one step within larger forms; a field component replaces the control where the choice happens.
How does the design let floor plans change without a code release?
Show answer
Plans are SVG files stored in a Floor Plan table and linked to rooms by id.
What was the fallback if RoomPicker failed in production?
Show answer
Switching the field back to the standard lookup control on the form, without a release.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.