无法在 sitecore 项目上设置工作流和工作流状态属性 [英] Can't set workflow and workflow state properties on sitecore items

查看:40
本文介绍了无法在 sitecore 项目上设置工作流和工作流状态属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开展一个项目,该项目要求我设置一个非常简单的 sitecore 工作流程.在修改现有项目以使用我的新工作流程时,我遇到了一些困难.这就是我所做的:

I am currently working on a project that requires me to set up a very simple sitecore workflow. I am running into some difficulties when modifying the existing items to use my new workflow. This is what i did:

当内容管理器开始编辑项目并在点击提交按钮时发布项目时,工作流会创建一个新版本.

The workflow creates a new version when a contentmanager starts editing an item and publishes the item when the submit button is clicked.

我将这些工作流项添加到了模板的标准值中:

I added these workflow items to the standard values of my templates:

下一步是在现有项目上设置工作流设置.幸运的是,我们可以使用 sitecore-powershell 来为我们做这件事.

The next step would be to set the workflow settings on the already existing items. Luckily we can use sitecore-powershell to do this for us.

function SetWorkflow($item)
{
    $item.__Workflow = "{DE29E564-3157-4CAB-81B1-87DF2E983517}";
    $item."__Workflow state" = "{27633BF0-B76A-4450-A139-BA53F6943778}";
}

get-childitem . -recurse -Language * | foreach-object { SetWorkFlow($_) }

这个脚本运行没有错误.

This script runs without errors.

现在有趣开始了:当我打开项目时,我在工作流和工作流状态属性上运行了这个脚本并没有改变.奇怪的是,编辑说空值是从标准值继承而来的,虽然标准值不为空,但我已经设置了这些!

Now the fun starts: When I opened the items I ran this script on the Workflow and Workflow state properties haven't changed. Weirdly enough, the editor says that the empty values are being inherited from the standard values, though the standard values are not empty, i have set these!

您会说脚本可能已失败并且未设置任何值.除了在 sitecore-powershell 中查找值时,我可以看到值在那里.

You'd say that the script maybe has failed and that no values have been set. Except when I look the values up in sitecore-powershell, i can see that the values are there.

get-childitem . -recurse -Language * | Format-Table Id, Language, __Workflow, "__Workflow state"

ID                                                          Language                                                    __Workflow                                                  __Workflow state
--                                                          --------                                                    ----------                                                  ----------------
{208D79B1-5B42-4713-A7F9-F2109588F639}                      en                                                          {DE29E564-3157-4CAB-81B1-87DF2E983517}                      {27633BF0-B76A-4450-A139-BA53F6943778}
{208D79B1-5B42-4713-A7F9-F2109588F639}                      nl-NL                                                       {DE29E564-3157-4CAB-81B1-87DF2E983517}                      {27633BF0-B76A-4450-A139-BA53F6943778}
{3F3B1132-02DA-4E75-928F-BDB8AED5C3CD}                      nl-NL                                                       {DE29E564-3157-4CAB-81B1-87DF2E983517}                      {27633BF0-B76A-4450-A139-BA53F6943778}
{8AF23DC5-E7FE-47E3-AC65-AA3D41D81F97}                      en                                                          {DE29E564-3157-4CAB-81B1-87DF2E983517}                      {27633BF0-B76A-4450-A139-BA53F6943778}
{8AF23DC5-E7FE-47E3-AC65-AA3D41D81F97}                      nl-NL                                                       {DE29E564-3157-4CAB-81B1-87DF2E983517}                      {27633BF0-B76A-4450-A139-BA53F6943778}

etc.etc.

我尝试手动设置项目的工作流和工作流状态属性.这有点工作,我可以完成一次工作流程.添加新版本时,工作流和工作流状态属性默认恢复为空"标准值,这会破坏该项目的工作流.

I tried setting the workflow and workflow state properties on the items by hand. This works kinda, i can go through the workflow once. When a new version is added the workflow and workflow state properties default back to their 'empty' standard values which breaks the workflow for that item.

有人知道这里发生了什么吗?如何一劳永逸地设置工作流和工作流状态属性?

Does anyone know what's happening here? How can I set the workflow and workflow state properties once and for all?

推荐答案

在基本模板的标准值上,您是否在 Workflow 字段上设置了工作流?它实际上需要在 Default workflow 字段上设置.其他 3 个字段是当前状态"字段,即它存储项目当前处于工作流的哪个阶段,这些应在您的模板和标准值中留空.

On the Standard Values of your base template, did you set the workflow on the Workflow field? It actually needs to be set on the Default workflow field. The other 3 fields are "current state" fields, i.e. it stores which stage of the workflow the item is currently in, these should be left blank in the your template and standard values.

来自 Sitecore 工作流程参考:

将工作流分配给项目

默认情况下,项目在创建时不会放置在工作流程中.Sitecore 仅在工作流程中放置项目如果为相应的数据模板标准值项目设置了初始"工作流程.最初的工作流对应于标准模板中的默认工作流字段.

By default, items are not placed in a workflow when created. Sitecore only places items in a workflow if the "Initial" workflow is set for the corresponding data template standard values item. The Initial workflow corresponds to the Default Workflow field in the Standard Template.

这篇关于无法在 sitecore 项目上设置工作流和工作流状态属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆