我像往常一样分配了工作流程。我尝试了以下代码,但没有获得任何项目....如果您有任何或帮助我获取项目,请分享任何示例代码
Database masterDatabase = Factory.GetDatabase("master");
Item currentItem = masterDatabase.Items["/sitecore/content/Home"];
IWorkflow workflow = masterDatabase.WorkflowProvider.GetWorkflow(currentItem);
WorkflowState state = workflow.GetState(currentItem);
答案 0 :(得分:0)
尝试使用SecurityDisabler
using (new SecurityDisabler())
{
var db= Factory.GetDatabase("master");
var item = db.Items["/sitecore/content/Home"];
// getting the item's workflow reference
var wf = this.database.WorkflowProvider.GetWorkflow(item);
// here we need either to login as a user with appropriate permissions
// to have access to workflow states/commands or disable security
wf.Start(item);
}
答案 1 :(得分:0)
该API仅适用于启用了工作流的站点上下文。要么在<sites>
配置中启用它,要么在代码周围使用上下文切换块。