Sharepoint 2013 Troubleshooting: Workflows failed to publish / something went wrong
Problem Description
Workflow error
Users are unable to publish new or existing 2013 workflows from SharePoint Designer to subsite. All attempts to publish 2013 workflows in this subsite fail with an error...
Microsoft.Workflow.Client.InvalidRequestException: Scope is not in an updatable state. Its current state is 'Unregistered' Microsoft.Workflow.Client.InvalidRequestException: Scope '/SharePoint/default/ee24f72e-04d0-420c-8264-cfbbc83ffd76/867bb878-7803-4b19-a8b3-f642b4315e94' is not in an updatable state. Its current state is 'Unregistered'. HTTP headers received from the server - ActivityId: 7c0b71ae-78a5-466c-b244-2d63303e38e4. NodeId: ASP2013. Scope: /SharePoint/default/ee24f72e-04d0-420c-8264-cfbbc83ffd76/867bb878-7803-4b19-a8b3-f642b4315e94. Client ActivityId: 6d99399f-e005-b0aa-d004-0beeb6698e25. ---> System
Browser Error:
Something went wrong, To try again, reload the page and then start the workflow.
Cause:
As the error indicates, workflow publishing failed because the Workflow Manager scope for the site was in an unregistered state. We verified that the scopes for the sit and the subsite were listed as unregistered in the Workflow Manager Resource database (WFResourceManagementDB).
When a site collection is deleted, SharePoint signals the Workflow Manager farm to unregister the scopes for that site and all child subsites. As a result, WFM deletes all in-progress workflow instance data related to the site as well as the internal links that make workflow history possible. The site was restored from the site collection recycle bin using Restore-SPSite, but restoring a deleted site does not re-register WFM scopes related to the site. Since the entire site had been deleted, the WFM scopes for all subsites within this site collection were also in an unregistered state.
Resolution:
To resolve this issue, I deleted unregistered scope related to the site and its child subsites.
With no scope entry for a given site/subsite, SharePoint will re-create the entry the next time a 2013 workflow is published to that site.
1) Powershell
From a SharePoint server, Open PowerShell_ISE as Admin and identify the ID of the affected subsite by using below script.
Add-Pssnapin “Microsoft.SharePoint.PowerShell”
$webUrl = '
https://global.sharepoint.com/sites/sp/workflow
'
(Get-SPWeb $webUrl).ID
2) SQL Instance
Open the SQL instance for the Workflow Manager which is hosting the Workflow Manager databases, confirm that the scopes are actually unregistered by running the below Queries.
a) Find the scope(s) related to the subsite by using below Query:
--===============================
-- Use the
web ID
here...
DECLARE @webID nvarchar(50) = '
867bb878-7803-4b19-a8b3-f642b4315e94
'
--Change below to correct
resource management DB
name if needed
USE [
WFResourceManagementDB
]
SELECT s.ScopeId, s.ParentScopeId, s.Path,
``s.Status, s.HasTopic, s.Description,
``s.RevisionNumber, s.Created, s.LastRevised,
``s.DisplayName, s.RowVersion
``FROM Scopes s WITH(nolock)
``WHERE description = @webID
``OR path like '%'+@webID+'%'
``ORDER BY s.Path
--===============================
b) Using the ParentScopeId values from the output of 2a, find the parent scope..
--===============================
``-- Use
ParentScopeId
from
2a
here...
``DECLARE @parentScopeId uniqueidentifier = '
EABD89EE-B1A9-C480-D381-4EF089DD2617
'
``--Change below correct
resource management DB
name if needed
``USE [
WFResourceManagementDB
]
``SELECT s.ScopeId, s.ParentScopeId, s.Path,
``s.Status, s.HasTopic, s.Description,
``s.RevisionNumber, s.Created, s.LastRevised,
``s.DisplayName, s.RowVersion
``FROM Scopes s
``WHERE s.ScopeId = @parentScopeId
``--===============================
Note: We are just making sure with the above two Queries to confirm that the scopes are Unregistered.
3) Identify and delete the related unregistered scopes as needed.
- Identify the related scopes, using same value from @ParentScopeId from 2b above. (If this doesn't work use below one)
Use the below Query, I just passed the Web Id instead of the parent scope id. To check the status of the scope is “Unregistered”.
SELECT * FROM Scopes s WITH (nolock)
WHERE s.Path like '%
867bb878-7803-4b19-a8b3-f642b4315e94
%'
We will only want to delete the scopes from this result set that are in an unregistered state.
- Delete only the unregistered scopes, using the same value from @ParentScopeId from 2b above. (If this doesn't work use below one)
I just passed the Web Id instead of the parent scope id (as explained earlier). You could see that the result is “Unregistered”. And you can delete this unregistered scope.
DELETE FROM Scopes
WHERE Path like '%
867bb878-7803-4b19-a8b3-f642b4315e94
%'
AND Status = 'Unregistered'
4) Republish
Re-published all 2013 workflows within the affected sites / subsites now it worked :).