Validation Message in Sitecore Content Hub
Problem Statement:
Display the validation error message when the save button is clicked. While creating or updating entities in Sitecore Content Hub, we may have requirements to validate the author inputs based on a pre-defined condition, such as image extensions not being allowed except PNG and JPEG, checkboxes must be checked, or field values not being empty.
In this blog, I am taking an example of a validation message that triggers if a field value is empty.
Solution:
To implement this functionality, you need to perform the following steps:
Step 1: Create a Script, paste the following script, and check whether the field value is null or empty. You can modify it as per your requirements.
See the blog post to Create a Script, Action, and Trigger in Sitecore Content Hub.
Step 2: Create an Action and choose the above script.
Step 3: Create a Trigger and choose the execution type as “In process”. Select the condition using the respective entity type. Go to the Actions tab and choose Action under the Validation Action section:
Step 4: Go to the Search page create a new entity and click on the save button without entering data in the Title field. You will get the validation message below:
Happy Sitecoreing 😊
Comments
Post a Comment