Everyday Dynamics 365 Form JavaScript: Read-Only Fields, Lookup Filters, Autocomplete and Metadata
Alongside the Web API series, this blog has carried a handful of very short posts over the years — a code snippet, a sentence of explanation, and not much else. Individually they were notes I wrote so I would not have to work the same thing out twice. Together they cover something more useful: the small pieces of JavaScript and metadata plumbing you end up needing on almost every Dynamics 365 form. I have merged five of those posts into this one, kept the code exactly as it worked, and added the context that was missing the first time round: when to use each one, what breaks, and what has changed now that Xrm.Page is deprecated. 1. Make every field on a form read-only This comes up whenever a record reaches a state where it should be locked — an approved order, a closed case, a submitted application. Rather than disabling forty fields one at a time in business rules, walk the controls collection and disable everything. function makeFieldsReadOnly() { var controls = Xrm....