2010-12-30 8 views
4

워크 플로에 콘텐츠 형식이 연결되어 있습니다. 나는 동일한 콘텐츠 유형의 이벤트 수신자에서 코드를 뽑아 내려고한다. 따라서 항목이 업데이트 될 때 특정 상태 (상태 = 검토 준비 상태)가 있으면 시작한다.Sharepoint 2010 프로그래밍 방식으로 워크 플로 시작

//이 줄은

var assoc = properties.Web.ContentTypes["Experiment Document Set"] 
     .WorkflowAssociations.GetAssociationByName("Experiment Review Workflow", 
      ultureInfo.CurrentUICulture); 

가 // 내가 온라인으로 볼 뭔가에서이 줄을 사용하려고했던 워크 플로 연결을 찾을 않지만, 널 (null)

assoc = properties.Web.WorkflowAssociations 
    .GetAssociationByName("Experiment Review Workflow", 
     CultureInfo.CurrentUICulture); 

다음 줄을 반환

var result = properties.Web.Site.WorkflowManager 
         .StartWorkflow(properties.ListItem, assoc,string.Empty, 
             SPWorkflowRunOptions.Synchronous); 

System.ArgumentException: Workflow failed to start because the workflow is associated with a content type that does not exist in a list. Before re-starting the workflow, the content type must be added to the list.

: 오류를 제공합니다

내가 갱신되는 목록 항목의 내용 유형을보고했다,이 문제를 확인하려면

properties.ListItem.ContentType.Name "Experiment Document Set" 

그래서 기본적으로 나는 콘텐츠 유형 "실험 문서 설정"과 관련된 workfow이 올바른 것입니다. "Experiment Document Set"의 이벤트 수신기에서 워크 플로를 시작하려고하면 "Experiment Document Set"이라는 콘텐츠 유형이 목록에 존재하지 않는다는 오류가 발생합니다.

답변

0

assoc.Enabled = true로 설정하십시오.

0

도움이 되기에는 너무 늦었지만 StartWorkflow 방법에서는 String.Empty (또는 null)을 사용할 수 없다는 것을 알았습니다.

http://www.tonytestasworld.com/post/Howto-Start-a-Sharepoint-Workflow-Programmatically.aspx에서 assoc.AssociationData은 구성 매개 변수없이 간단한 워크 플로에서 작동합니다.

처음에는 두 단계 코드 예제에서 언급 한 문제와 비슷한 단계가 있기 때문에 아직 테스트 할 수 없습니다.

관련 문제