A field technician app built as a model-driven app needs a code component that lets users take a photo with the device camera and attach it to the current record. Which implementation is correct?
Select an answer to reveal the explanation.
Short Explanation
The framework already has a camera button for you: context.device.captureImage. You just have to declare it in the manifest first, and it hands back the photo as a file you can attach.
Full Explanation
The component framework's Device API exposes device capabilities through context.device, including captureImage, captureAudio, captureVideo, getBarcodeValue, getCurrentPosition and pickFile. captureImage opens the device camera with optional settings, such as image size and quality, and returns a promise that resolves to a file object containing the file name, MIME type and contents, which the component can then save to the record, for example by creating a note or setting a file or image column through the Web API. Because device access is a declared capability, the manifest must include a uses-feature entry for Device.captureImage inside feature-usage. Calling browser media APIs directly from the component bypasses the framework, behaves inconsistently across hosts such as the mobile app's web view, and ignores the supported API; the premise that the framework lacks camera access is false. lookupObjects opens the platform lookup dialog to select Dataverse records and has no connection to device hardware. pickFile lets the user choose an existing file, and its behavior depends on the device's file picker, so it does not guarantee a direct camera capture. Exam caveat: device features are designed for mobile hosts, so the experience on a desktop browser may differ. Operational check: run the app in the mobile client, capture a photo, and confirm the record shows the attachment.