## TL;DR

Set WhoId - the Id of the lead or contact the call was with - on every Task the agent creates, and validate required fields client-side before the API call. The task needs to hang off someone; without the relation, Salesforce rejects it.

```text
salesforce REQUIRED_FIELD_MISSING on task create  -  agent's call-logging step missing WhoId
```

## Steps

1. Resolve the lead or contact Id for the call target and include it as WhoId in the task payload, along with Subject and Status. Expected: the create call returns a Task Id instead of REQUIRED_FIELD_MISSING.

2. Validate the payload client-side before sending: WhoId present, Subject non-empty, Status a valid value. Expected: malformed payloads are caught before the API call, not after.

3. If the call target is not a person record - for example logging against an Account - use WhatId instead and leave WhoId out. Expected: account-level tasks succeed with WhatId set.

4. Write the returned Task Id back to the run record so the call log is traceable. Expected: every logged call has a Task Id stored against it.

## Use this when

- the agent's call-logging task create fails with REQUIRED_FIELD_MISSING
- tasks fail because WhoId was never set
- call logging works for some records but not others

## Not for this skill when

- Event objects - they have their own required fields and semantics
- tasks created by flows or process automation - fix those in the flow, not the agent
- a missing required custom field - same pattern, but the field to set is org-specific

## Variant phrasings

### REQUIRED_FIELD_MISSING on task create

Same root cause: a required relation field was left empty.

### call logging fails over the API

Same fix: include WhoId and pre-validate the payload.

### missing WhoId on task

Same fix: resolve the person Id first, then create.

## Why it happens

Task is a relational object: depending on org configuration it requires a who (a person: lead or contact), a what (an account, opportunity, or similar), or both. The agent built the task body - subject, notes, call outcome - but never attached it to the person the call was with. Salesforce rejects the orphan task at write time, so every call the agent 'logged' actually vanished.

## Edge cases

- Person accounts blur the who/what line - confirm which Id the org expects before standardizing.
- Some orgs require both WhoId and WhatId - check the org's validation rules, not just the API error.
- Shared activities (multiple contacts on one task) need the task relation object, not a single WhoId.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_SQN0D6vGkYtaM2ZGHips8Q
