Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Customizing the association XML of Publishing workflow - not working

$
0
0

We are creating a site definition. In that we have a Pages library and by default Publishing workflow should be attached to the Library with "CurrentSite Members" as the Approvers. We have constructed the XML fine. While we test that, the approval field is showing empty in the association form. 

 using (SPSite oSite = new SPSite("http://c4des115:1471/sites/testttt"))
            {
                using (SPWeb oWeb = oSite.OpenWeb())
                {
                    SPList oList = oWeb.Lists["Pages"];
                    SPDocumentLibrary oLibrary = oList as SPDocumentLibrary;
                    SPWorkflowTemplate wflTemplate = oWeb.WorkflowTemplates.GetTemplateByName("Publishing Approval", System.Globalization.CultureInfo.CurrentCulture);
                    SPList wflTaskList = oWeb.Lists["Workflow Tasks"];
                    SPList wflHistoryList = oWeb.Lists["Workflow History"];
                    SPWorkflowAssociation wflAss = SPWorkflowAssociation.CreateListAssociation(wflTemplate, "Handbook Content Approval workflow", wflTaskList, wflHistoryList);
                    wflAss.AutoStartChange = true;
                    wflAss.AutoStartCreate = true;
                    wflAss.AllowManual = false;                    
                    oWeb.AllowUnsafeUpdates = true;
                    oList.WorkflowAssociations.Add(wflAss);
                    oList.Update();
                    oWeb.AllowUnsafeUpdates = false;
                    SPWorkflowAssociationCollection wfAssociationColl = oLibrary.WorkflowAssociations;
                    SPWorkflowAssociation wfAssociation = wflAss;
                    CultureInfo cultInfo = new CultureInfo(1033);
                    // get association data which contains the workflow properties
                    string data = wfAssociation.AssociationData.ToString();
                 
                    string newData = "<d:Assignee><pc:Person><pc:DisplayName>testttt members</pc:DisplayName><pc:AccountId>testttt members</pc:AccountId><pc:AccountType>SharePointGroup</pc:AccountType></pc:Person></d:Assignee>";
                    data = data.Replace("<d:Assignee />", newData);

                    wfAssociation.AssociationData = data;
                    wfAssociation.Enabled = true;                
                    oLibrary.WorkflowAssociations.Update(wfAssociation);
                    
                  

                   
                }
            }


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>