I can publish an item with a blank field that have validation rule where required. How can I use workflow to prevent publish item with a blank field?
3 Answers
Yes, it is possible to do this without customization. Sitecore has the special validation rule that is named "Required", which checks fields that contain the value.
You can find it in Sitecore/System/Settings/Validation Rules/Field Rules.
Please, configure the workflow and validation rules for your template, in this way:
In the "master" database open template, whose fields you want to check before publishing.
Go to the template field item, - that must be validated
In the section "Validation Rules", in the "Workflow" field, select the "Required" validation rule. Note: If you want that your users got the notifying that the field must contain a value when they edits item, set the "Required" rule to the other fields in this section.
Then, go to "__Standard Values" item of your template and in "Workflow" section (in "Standard Fields") set the "Default Workflow" field to "Sample Workflow".
Please have a look on these links:
For absolutely required validation rules, I sometimes set the "Parameters" field for the validation rule to include the "Result=FatalError" which then won't allow users to change an item until the field is filled in.
Other options for Result parameter include:
- Suggestion
- Warning
- Error
- Critical Error
Only the FatalError setting will force the user to resolve the validation rule before they are allowed to save. The others will display the appropriate message but will still allow users to save the item.
-
This works well for saving normal changes (like updating field values) but will not prevent workflow actions (like the Submit action).– MichaelCommented May 9, 2023 at 14:42
Just assign the item with appropriate workflow and it will not be included in publishing. The default behavior of Sitecore is if the item is in workflow (draft or awaiting approval), it will exclude the item to get published.
Also if you have a validation rule applied and then also if you are able to save the item, check is there any JS error which is preventing the validation to get executed or not. Just a thought.
Hope this helps or let me know.