DataMaskPolicy defines a masking policy for Data Mask & Seed. It manages the policy definition and run frequency as org metadata, so you can promote policies through deployment pipelines and copy consistent configurations across orgs and sandboxes.
Deploying a policy is not the same as executing or monitoring a masking job. The Data Mask & Seed app is available in production and sandboxes, but masking jobs run only in sandboxes. Production data is never masked.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
The metadata component's identity, inherited from Metadata. It is distinct from the policy's display label. |
label |
Required master label for the policy. |
description |
Optional explanation of the policy's intent. It does not establish which sensitive fields have actually been masked. |
locale |
Locale for generated masking data, not the user's interface language. It defaults to en_US when omitted. Supported locale codes include en_GB, fr_FR, and ja_JP. |
policyType |
Exposed policy classification with values dataMask and generate. The metadata type name does not establish which value an individual policy uses. |
runFrequency |
Optional run frequency: once, daily, weekly, or monthly. Omitting it leaves the policy without a scheduled run frequency. A recurring frequency also needs a scheduled start time configured in Setup. |
runOnRefresh |
Whether the policy runs automatically when a sandbox is created or refreshed. Accepts true or false; the default is false. This trigger is separate from runFrequency. |
scheduledStart |
Exposed date-time element, but its presence does not mean Metadata API supports deploying a scheduled start time. Configure ScheduledStart in the Data Mask & Seed Setup UI. |
lastRunDate |
Exposed date-time element, but its presence does not mean Metadata API supports retrieving run history. View LastRunDate in the Data Mask & Seed Setup UI. |
Behavior and Constraints
Access prerequisites
A production org must have the Salesforce Data Mask license. The deploying user must have both of these assignments:
-
DataMaskAndSeedUserPsl, the permission set license that grants eligibility for the permission set. -
DataMaskAndSeedUser, the permission set that requires that license.
Assign the permission set license first. Missing required access can cause an insufficient-access error or make the Data Mask management screens unavailable. Server-side validation and access controls enforce business rules through Metadata API as well as other access paths.
Refresh triggers and recurring schedules
runOnRefresh controls automatic execution when a sandbox is created or refreshed. It does not configure a recurring schedule. Conversely, setting runFrequency does not enable the sandbox creation or refresh trigger.
A recurring frequency alone is not enough to execute a schedule. Set the scheduled start time in the Data Mask & Seed Setup UI. Recurring schedules run only in sandboxes.
When runFrequency is omitted, the policy has no scheduled run frequency and can be triggered manually from Setup or the Connect API. The separate runOnRefresh setting still controls automatic execution on sandbox creation or refresh.
Metadata API does not provide job execution, monitoring, or run-history operations. Use the Data Mask & Seed Setup UI to set the scheduled start time, run and monitor jobs, and view the last run date.
What a policy does not prove
A successful deployment, or a policy with runOnRefresh set to true, does not by itself show that a masking job has completed or that every sensitive field is covered. That assessment requires the actual policy configuration and execution information. Neither the policy's description nor its metadata type name establishes the masking coverage.
Deployment and Retrieval
DataMaskPolicy components use the .dataMaskPolicy suffix and reside in the dataMaskPolicies folder. Include them in package.xml, the deployment or retrieval manifest, with the type name DataMaskPolicy and the component's metadata name, such as Sample_Data_Mask_Policy.
The type supports the * wildcard in the manifest. See Deploying and Retrieving Metadata with the Zip File for manifest-based deployment and retrieval.
A policy with runOnRefresh set to true can deploy successfully to production. That deployment does not start a production masking job. The automatic masking trigger applies when a sandbox is created or refreshed.
Do not treat the exposed scheduledStart and lastRunDate elements as deployable scheduling configuration or retrievable run history. ScheduledStart configuration and LastRunDate viewing are unavailable through Metadata API. Policy deployment and retrieval manage the definition and run frequency, not the job's operational state.
If deployment fails with an insufficient-access error, check the production org's Data Mask license and both user assignments. The permission set alone is not sufficient without its required permission set license.
Relationships
DataMaskPolicy extends the Metadata base type and inherits fullName. DataMaskSettings is a separate metadata type; it and DataMaskPolicy work independently. Do not treat the settings type as a prerequisite for a policy deployment.
Common Questions
Can I deploy a DataMaskPolicy to production?
Yes. A policy can deploy to production even with runOnRefresh set to true. The production org needs the Salesforce Data Mask license, and the deploying user needs the required permission set license and permission set. Masking jobs still run only in sandboxes.
Why does my daily DataMaskPolicy not run?
runFrequency set to daily is not enough to execute a recurring schedule. Configure the scheduled start time in the Data Mask & Seed Setup UI, and use a sandbox. Recurring schedules do not run in production.
Can I deploy the scheduled start time or retrieve the last run date through Metadata API?
No. Although scheduledStart and lastRunDate are exposed elements, Metadata API does not support ScheduledStart configuration or LastRunDate viewing. Use the Data Mask & Seed Setup UI for those tasks.
Does runOnRefresh mean all sensitive data has already been masked?
No. It enables automatic policy execution when a sandbox is created or refreshed. It does not prove that a job has completed or that every sensitive field is covered. Check the actual policy configuration and execution information.
Does DataMaskPolicy require DataMaskSettings?
No. They are separate metadata types that work independently. A policy deployment does not require DataMaskSettings as a prerequisite.