5

Is there a simple way of stopping user from saving and publishing when a field is empty?

0

1 Answer 1

10

1) Publishing

To stop publishing when field is empty, there is no OOTB functionality. One option how you can achieve it with minimal effort is to put item (template) under workflow and use below approach to disable saving item when field is empty.

This will force content editors to fill in field values before saving and proceeding to next step of workflow. Afterwards they need to finish workflow and publish. Publish can be then manually or automatically when workflow is pushed to last step.

Without filling field, publishing won't be also possible.

2) Saving

You need to apply validation rules and especially FatalError to prevent saving of item when field is empty.

To achieve this you need to:

  1. Create similar validation rule as "Required" validation rule which is OOTB to achieve checking whether field is empty. By similar I meant exact copy (:-)) of '/sitecore/system/Settings/Validation Rules/Field Rules/Required' item
  2. Configure validation rule as FatalError - this will halt saving of item when validation fails - Set Result=FatalError as value of Parameters field in your validation rule

enter image description here

  1. Assign validation rule for your item template - to be sure item is not saved in every scenario, you need to select the Validation Rules` section in item template and select the rules to apply in the fields “Quick Action Bar", “Validate Button”, “Validator Bar” and the “Workflow”.

enter image description here


More information

Validation rules:

FatalError validation:

1
  • When I choose "Insert item", a dialog pops up asking me for the name of the new item. And then (AFAIK) the new item is immediately saved, with usually all fields empty; please correct me if I'm wrong. Assuming this is correct, would having validation rule(s) as you describe prevent the initial (automatic) save from actually happening? Or do the validation rules apply only after the initial (automatic) save?
    – Peter B
    Commented Feb 27, 2019 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.