none
List.WorkflowAssociations is empty

    질문

  • Greetings!

    I've created WF which i need to start on  major version publishing.  Some time ago i  succeeded to bind WF on this event by simple  PS-script  like:

    $web = get-spweb -identity "*Site URL*"
    $mylib = $web.Lists["*Library Name*"]
    $wa_guid = ($mylib.WorkflowAssociations | where {$_.Name -like *Workflow unique name*}).Id
    $mylib.DefaultContentApprovalWorkflowId = $wa_guid
    $mylib.Update()

    And this worked  those days, but no now. Now i successfully can publish the  WF, i can start it and complete it, but the $mylib.WorkflowAssociations property is still empty.  Property is read-only and i cannot add an object there manually.   I've tried to add subscription  to  sample PS-created WF by  Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager instance and it was ok, but  this association also has not saved in WorkflowAssociations property. 

    I've tried another WF and another  list - the situation is the same. I've tried WF2010 -  WorkflowAssociations property got it's content in this case.  I've checked  another created some time ago lists and WF's - WorkflowAssociations  is not empty.

    I have no idea what could be wrong and asking for any advice or idea.

    2018년 6월 15일 금요일 오전 6:15

모든 응답

  • Hi,

    List.WorkflowAssociations won't include SharePoint 2013 platform workflows only return SharePoint 2010 platform workflows.

    The right way to get the SharePoint 2013 workflows is using WorkflowServicesManager like the script below:

    $web = Get-SPWeb "http://sp/sites/dev"
    
    $wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
    $sub = $wfm.GetWorkflowSubscriptionService()
    $list = $web.Lists["doc2"]
    $WF = $sub.EnumerateSubscriptionsByList($list.ID) | Where-Object {$_.Name -eq "doctest13"}
    Write-Host $WF

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    18시간 20분 전