You’ve hit a common gotcha with Knowledge API custom field validation and automated publishing workflows. Here’s the complete solution:
Root Cause:
Knowledge API treats publishing as creating a new article version, not just a status change. Custom fields marked as required must be explicitly provided in the publish request, even if they exist on the draft version. The UI handles this automatically by copying field values, but the API requires explicit specification.
Solution for Knowledge API Required Fields:
- Query the Draft Version First:
Before publishing, retrieve all custom field values from the current draft:
GET /services/data/v60.0/sobjects/Knowledge__kav/{articleId}
// Include all custom fields in query
- Include Custom Fields in Publish Request:
When calling the publish action, include ALL required custom fields:
PATCH /services/data/v60.0/sobjects/Knowledge__kav/{articleId}
{
"ValidationStatus": "Published",
"Approval_Status__c": "Approved",
// Include any other required custom fields
}
Automated Publishing Workflow Fix:
Update your workflow to follow this pattern:
- Pre-Publish Validation: Query the draft article and verify all required custom fields have values
- Field Value Preservation: Store these field values in your workflow state
- Publish with Full Payload: Include all required custom fields in the publish API call
- Post-Publish Verification: Query the published version to confirm field values persisted
Handling Multi-Language Articles:
If you have translations, each language version needs the custom fields set independently. Loop through all translations and apply the same field values to each version before publishing.
Custom Field Validation Rules:
Review your validation rules on the Knowledge__kav object. Make sure they’re not triggering during the Draft→Published transition. Add a condition to exclude validation during status changes:
AND(ISCHANGED(ValidationStatus), ValidationStatus = 'Published')
Best Practice for Content Lifecycle Automation:
- Create a custom field mapping configuration that defines which fields must be included in publish requests
- Build a reusable function that queries draft values and constructs the complete publish payload
- Add logging to track which fields are missing when publish fails
- Implement a pre-flight check that validates all required fields before attempting publish
This approach has resolved similar issues for several clients. Your 50-60 articles per week should flow smoothly once you’re explicitly passing custom field values in the publish API calls.
This draft is based on general Salesforce knowledge. It has not been verified against your specific version and environment. Practitioners: verify the steps and share your experience below.