Publishing workflow always discards page
-
09-12-2019 - |
Question
I have a publishing web with unique permissions. I have tried changing the default approvers group through code by doing the follwing:
- Locate Pages list
- Locate workflow association by list.DefaultContentApprovalWorkflowId
- Update AssociationData and change DisplayName and AccountId to "CustomApprovers" (which is a sharepoint group.
- Call list.WorkflowAssociations.Update with the association.
It seems to work fine until I try to submit a page for approval. Sharepoint shows the "Processing" page, but when it completes the page is always discarded. It also does not add a task to the approval task list. Why does this happen? Am I missing a step?
Things I've tried:
- Change it to a group that does not exist: Validation error when submitting.
- Change AccountId to the group id: Validation error when submitting.
- Change the AccountType to SpGroup: Page is automatically discarded.
- Not change anything (use default settings): Page is submitted correctly.
Solution
The reason it did not work was because I was manipulating the AssociationData using XDocument. When I dumped the xml back into the string it attached
<?xml version="1.0" encoding="utf-16">
at the top which in turn caused the xml to be rejected in some weird way. Doing a regular string replace worked just fine.
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange