Introduction
For Salesforce Developers, Administrators, and Architects working within Health Cloud, encountering field writeability errors during Apex execution, data integrations, or API updates is a common hurdle. One specific error that frequently arises when dealing with clinical data models is the inability to write to the PatientId field on the PatientImmunization object.
If your code or integration is failing with this exception, the root cause is almost always related to missing user permissions rather than an inherent system limitation.
Below is the exact error you might be seeing, followed by the straightforward resolution and best practices for managing Health Cloud permissions.
The Error Context
When attempting to insert or update a PatientImmunization record, the system throws an exception indicating that the user lacks the required access to modify the PatientId lookup field.
Here is the exact exception snippet:
Exception:
Line: 1, Column: 8
Field is not writeable: PatientImmunization.PatientId
The Root Cause
In Salesforce Health Cloud, access to specific clinical data objects like PatientImmunization is heavily gated by feature-specific permission sets. Even if a user profile has “Modify All Data” or System Administrator privileges, certain Health Cloud objects require explicit feature licenses and permission sets to grant full Read/Write/Edit capabilities. Without the proper permission set, the fields on these objects default to read-only or are completely hidden from the user context, throwing a “Field is not writeable” Apex exception.
The Resolution
To resolve this issue, you must grant the integration user, administrator, or standard user the specific Health Cloud permission set that unlocks access to these clinical objects.
Solution: Assign the “Manage Home Health” Permission Set to the affected user.
Step-by-Step Fix:
- Navigate to Setup in Salesforce.
- In the Quick Find box, type Users and select it.
- Click on the name of the user encountering the exception.
- Scroll down to the Permission Set Assignments related list and click Edit Assignments.
- Locate the Manage Home Health permission set in the Available Permission Sets list.
- Click the Add arrow to move it to the Enabled Permission Sets list.
- Click Save.
Once assigned, the user will have the necessary field-level access to write to PatientImmunization.PatientId, and the integration or Apex transaction will proceed successfully.