[英]Sitecore custom item validator
I need to make a custom item validator that checks on workflow final state about the language versions that exist for the particular item. 我需要创建一个自定义项验证器,用于检查有关特定项的语言版本的工作流最终状态。 I know I am supposed to inherit Sitecore.Data.Validators.StandardValidator, or Sitecore.Data.Validators.ItemValidators.WorkFlowFinalStateValidator, but what are the methods that are available to me on this?
我知道我应该继承Sitecore.Data.Validators.StandardValidator或Sitecore.Data.Validators.ItemValidators.WorkFlowFinalStateValidator,但是我可以使用哪些方法呢? Is there a way I can find this out?
有没有办法可以找到它?
Update: I created a custom validator using the StandardValidator class, and implementing the ValidatorResult method.
更新:我使用StandardValidator类创建了一个自定义验证器,并实现了ValidatorResult方法。 I then registered this class in the system/settings/validation rules section.
然后我在系统/设置/验证规则部分注册了这个类。 I then set the standard values fields for an item and this works in the regular Quick Bar validation rules, and the validation bar.
然后,我为项目设置标准值字段,这适用于常规的快速栏验证规则和验证栏。 I am able to see the error.
我能看到错误。
Now I want to use this in the workflow actions rules. 现在我想在工作流操作规则中使用它。 What do I need to do?
我需要做什么? I chose the new rule to set it in the workflow rules area in the standard values section of the item, but when I execute the command in the workflow, it just doesn't run... what am I missing?
我选择新规则将其设置在项目的标准值部分的工作流程规则区域中,但是当我在工作流程中执行命令时,它只是不运行...我缺少什么?
Our team works with StandardValidator as the base for any field validation we are doing, such as writing an AlphanumericValidator that will ensure a text field value is, well, alpha-numeric. 我们的团队使用StandardValidator作为我们正在进行的任何字段验证的基础,例如编写一个AlphanumericValidator,它将确保文本字段值是字母数字。
I'm not sure what you are intending to do with the language versions, but I know we were running some workflow actions to check if an Item had a version in another language to inform the user of the current state of translation. 我不确定你打算用语言版本做什么,但我知道我们正在运行一些工作流程动作来检查一个Item是否有另一种语言的版本来通知用户当前的翻译状态。 When an Approve action took place in a certain step, prior to final, we added a workflow action to kick off our code.
如果批准操作在特定步骤中发生,则在最终之前,我们添加了一个工作流操作以启动我们的代码。 Rather than using a validator, we actually implemented and registered an event handler.
我们实际上实现并注册了一个事件处理程序,而不是使用验证器。 It looked something like this:
它看起来像这样:
public void Process(WorkflowPipelineArgs args)
{
Item dataItemCurrentLanguage = args.DataItem;
Item dataItemOtherLanguage = GetItemInOtherLanguage(dataItemCurrentLanguage);
if (dataItemOtherLanguage != null && dataItemOtherLanguage.Versions.Count > 0)
{
//Insert what you want to check for here
if(isGood)
{
//Do something
}
else
{
Context.ClientPage.ClientResponse.Alert("Something bad!");
args.AbortPipeline();
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.