SubPointSolutions / spmeta2

SharePoint artifact provision for .NET platform. Supports SharePoint Online, SharePoint 2019, 2016 and 2013 via CSOM/SSOM.
http://subpointsolutions.com/spmeta2
133 stars 56 forks source link

Workflow get not deployed to Content Type #1135

Open EA12 opened 5 years ago

EA12 commented 5 years ago

It should be possible to attach a Workflow to a Content type.

Workflows got deployed to the web but are not attached to the Content type. Using: CSOM SharePoint Online SPMeta2 API: v4.0.30319

SPMeta2 model:


var consoleUtils = new ConsoleUtils();
    consoleUtils.TraceEvent += consoleUtils_TraceEvent;

    consoleUtils.WithO365Context(this.WebUrl, this.O365User, this.O365Pwd, context =>
    {
        CSOMProvisionService provisionService = new CSOMProvisionService();

        consoleUtils.TraceDeploymentProgress(provisionService);

        var model = SPMeta2Model.NewWebModel(webmodel =>
        {
            ContentTypeDefinition ct = ContentTypes.GetQMDokument();

            webmodel.AddContentType(ct, contentType =>
            {
                WorkflowAssociationDefinition wfCollect = new WorkflowAssociationDefinition
                {
                    TaskListTitle = "Aufgaben",
                    HistoryListTitle = "Workflowverlauf",
                    AllowManual = true,
                    Name = "Kenntnisnahme",
                    Description = "Lenkt ein Dokument zum Review. Reviewer müssen die Kenntnisnahme bestätigen. Der Besitzer des Dokuments wird informiert, wenn der Workflow abgeschlossen ist.",
                    WorkflowTemplateName = BuiltInWorkflowNames.CollectFeedbackSharePoint2010,
                    AssociationData = "<dfs:myFields xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:dms=\"http://schemas.microsoft.com/office/2009/documentManagement/types\" xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\" xmlns:q=\"http://schemas.microsoft.com/office/infopath/2009/WSSList/queryFields\" xmlns:d=\"http://schemas.microsoft.com/office/infopath/2009/WSSList/dataFields\" xmlns:ma=\"http://schemas.microsoft.com/office/2009/metadata/properties/metaAttributes\" xmlns:pc=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><dfs:queryFields></dfs:queryFields><dfs:dataFields><d:SharePointListItem_RW><d:Reviewers><d:Assignment><d:Assignee><pc:Person><pc:DisplayName>QM Reviewer</pc:DisplayName><pc:AccountId>QM Reviewer</pc:AccountId><pc:AccountType>SharePointGroup</pc:AccountType></pc:Person></d:Assignee><d:Stage xsi:nil=\"true\" /><d:AssignmentType>Parallel</d:AssignmentType></d:Assignment></d:Reviewers><d:ExpandGroups>true</d:ExpandGroups><d:NotificationMessage>Bitte lesen Sie das Dokument und bestätigen Sie die Kenntnisnahme!</d:NotificationMessage><d:DueDateforAllTasks xsi:nil=\"true\" /><d:DurationforSerialTasks>5</d:DurationforSerialTasks><d:DurationUnits>Day</d:DurationUnits><d:CC /><d:CancelonChange>true</d:CancelonChange></d:SharePointListItem_RW></dfs:dataFields></dfs:myFields>"
                };
                contentType.AddWorkflowAssociation(wfCollect);

                WorkflowAssociationDefinition wfApproval = new WorkflowAssociationDefinition
                {
                    TaskListTitle = "Aufgaben",
                    HistoryListTitle = "Workflowverlauf",
                    AllowManual = true,
                    Name = "Genehmigung",
                    Description = "Lenkt ein Dokument zur Genehmigung. Der Besitzer des Dokuments wird informiert, wenn der Workflow abgeschlossen ist.",
                    WorkflowTemplateName = BuiltInWorkflowNames.ApprovalSharePoint2010,
                    //AssociationData = "<dfs:myFields xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:dms=\"http://schemas.microsoft.com/office/2009/documentManagement/types\" xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\" xmlns:q=\"http://schemas.microsoft.com/office/infopath/2009/WSSList/queryFields\" xmlns:d=\"http://schemas.microsoft.com/office/infopath/2009/WSSList/dataFields\" xmlns:ma=\"http://schemas.microsoft.com/office/2009/metadata/properties/metaAttributes\" xmlns:pc=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><dfs:queryFields></dfs:queryFields><dfs:dataFields><d:SharePointListItem_RW><d:Approvers><d:Assignment><d:Assignee><pc:Person><pc:DisplayName>QM Genehmiger</pc:DisplayName><pc:AccountId>QM Genehmiger</pc:AccountId><pc:AccountType>SharePointGroup</pc:AccountType></pc:Person></d:Assignee><d:Stage xsi:nil=\"true\" /><d:AssignmentType>Parallel</d:AssignmentType></d:Assignment></d:Approvers><d:ExpandGroups>true</d:ExpandGroups><d:NotificationMessage>Bitte prüfen und genehmigen Sie das Dokument.</d:NotificationMessage><d:DueDateforAllTasks xsi:nil=\"true\" /><d:DurationforSerialTasks>5</d:DurationforSerialTasks><d:DurationUnits>Day</d:DurationUnits><d:CC /><d:CancelonRejection>true</d:CancelonRejection><d:CancelonChange>true</d:CancelonChange><d:EnableContentApproval>false</d:EnableContentApproval></d:SharePointListItem_RW></dfs:dataFields></dfs:myFields>"
                };
                contentType.AddWorkflowAssociation(wfApproval);
            });
        });

        provisionService.DeployWebModel(context, model);
    });

All related Artifacts are deployed before that model and the Content Type will be attached to a library afterwards.

From the Settings pages of Site-Content-Type and library I can see that no Workflow is attached but the WorkflowAssosiation is deployed to the web.

Side-Note: custom description of the WorkflowAssociationDefinition will be overidden with the default description of the provided WorkflowTemplateName.

Is related to following Yammer post: https://www.yammer.com/spmeta2feedback/#/Threads/show?threadId=974786701

SubPointSupport commented 5 years ago

Looking into this.

No exception is raised, it just deployed with no errors and bindings?

EA12 commented 5 years ago

Yep, no erros. If I navigate to the Workflow-Details, I can see that the Template-Field has no Workflow-Templates listed. It should be as in following screenshot but is empty: wf

So, may be there is something wrong with WorkflowTemplateName = BuiltInWorkflowNames.CollectFeedbackSharePoint2010