A code app must stamp each new request row with the signed-in user's Dataverse systemuser ID and their business unit ID. The developer wants one Dataverse call that returns both values for the current caller. Which approach should be used?
Select an answer to reveal the explanation.
Short Explanation
Asking Dataverse who you are is literally what WhoAmI is for. One call hands back your systemuser ID and your business unit ID. Don't swap in the Entra object ID; that's your ID card in a different building.
Full Explanation
WhoAmI is a Dataverse function that returns details about the calling user: UserId, which is the systemuser row ID, BusinessUnitId and OrganizationId. In a code app, the developer finds it with pa app find-dataverse-api and adds it with pa app add dataverse-api, which generates a WhoAmIService whose method returns those values for whoever is signed in. Querying systemuser by full name is unreliable because names are not unique and can change, and it costs an extra query with more privileges than needed. The Microsoft Entra object ID identifies the user in the directory, while the systemuser ID identifies the user's row in a particular Dataverse environment; the two are different GUIDs, so writing the object ID into a lookup fails or points nowhere. RetrieveCurrentOrganization returns information about the organization and its endpoints, not about the calling user or their business unit. Exam caveat: getContext in a code app also exposes the user's systemuser ID, but WhoAmI is the call that returns the business unit ID alongside it. Operational check: add WhoAmI, call it as two different test users, and confirm each response returns the expected systemuser and business unit IDs.