A PostOperation plug-in on the account Update message must read the email address of every active contact whose parentcustomerid is the updated account, then flag the account if any address is missing. Some accounts have hundreds of contacts. Which approach should the developer use?
Select an answer to reveal the explanation.
Short Explanation
One well-aimed query beats a hundred little trips. A QueryExpression with the right filter and just the column you need brings back the whole set in a single call. The trap is batching individual Retrieves; you're still asking a hundred times, just in one envelope.
Full Explanation
A single RetrieveMultiple call with a QueryExpression lets the plug-in express the relationship and the business filter on the server: the criteria restrict rows to contacts whose parentcustomerid equals the account ID and whose statecode is active, and the ColumnSet limits the returned data to emailaddress1. Dataverse executes one query and returns only what the logic needs, which keeps the plug-in fast inside the transaction and well within its execution time limit. Retrieving each contact individually requires knowing every contact ID in advance and costs one request per contact, so the plug-in's duration grows with the number of contacts. ExecuteMultiple is a batch message intended for client applications; using batch request types inside plug-ins is explicitly discouraged, and wrapping hundreds of RetrieveRequest messages still performs hundreds of retrievals. Requesting every column of each contact returns far more data than needed, increasing query cost and memory use, which is why retrieving all columns is called out as a performance anti-pattern. Exam caveat: if more than one page of results is possible, the code must page through results rather than assume one response. Operational check: trace the record count and elapsed time for an account with many contacts and confirm one query executes.