Skip to content
LearningPathX
Learning PathsFree TestsExam InfoHow it worksNews
Sign inChoose a certification
  1. Home/
  2. Certifications/
  3. AB-400/
  4. AB-400 Learning Path/
  5. Study FAQs/
  6. How can a model-driven JavaScript command read a saved row instead of unsaved form values?

Study FAQ

How can a model-driven JavaScript command read a saved row instead of unsaved form values?

Exam · AB-400Knowledge domain · Extend the user experience (25–30%)Updated Nov 25, 2026
Also asked as 2
  • How do I use PrimaryControl for a main-form command that reads Dataverse?
  • How can a main-form button check a saved account value safely?

Answer

For a JavaScript command on a model-driven main form, configure PrimaryControl and use it directly as the form context. Capture the current table and row ID, then use Xrm.WebApi.retrieveRecord to read saved Dataverse data under the signed-in user's access.

In an isolated Account form with a published web resource, capture primaryControl.data.entity.getId() before awaiting a result and strip any braces. If no row ID is present, ask the user to save before checking. For a saved account, Xrm.WebApi.retrieveRecord("account", id, "?$select=creditonhold") requests only the required column. A denied, missing or failed read should show an unavailable result. A grid command needs its own selection context and must handle its selection count.

A form event handler receives execution context, while this command receives form context directly. Avoid using retained form state after an asynchronous read. Keep the result associated with the captured ID and suppress obsolete responses where the host workflow requires it. Check the actual command's save behavior and display a saved value as a snapshot for the user.

Test an unsaved row, a saved row with unsaved edits, missing read privileges and navigation while a read is pending. A later business operation must enforce its own permission and current-state checks.

Form and grid command parameters · retrieveRecord · Client API execution context

Full explanation

AB-400: Client Scripting and Commands in Model-Driven Apps

Study guide · AB-400

Read the full explanation →
← Back to AB-400 FAQsView learning path →

Related questions

How do I use environment variables for a code app's data source? →How do I read Dataverse table metadata in a Power Apps code app? →How do I deploy a Power Apps code app into a specific solution and share it? →How do I initialize and run a Power Apps code app locally? →How do I find what is slowing down a Power Apps code app? →When should I use Power Fx or JavaScript for a model-driven command? →
LearningPathX

A focused path to certification, one clear step at a time.

© 2026 LearningPathX. All rights reserved.

Product

CertificationsLearning PathsFree TestsHow it worksNews

Company

SubscriptionHelp centerContact usPrivacyTerms

Follow us

Your privacy choices

We use analytics cookies to understand how LearningPathX is used and improve your learning experience. Analytics will only start after you accept.