9

We recently switched from code-first to Sitecore-first in our JSS project.

In the Sitecore-first approach we now use Unicorn to serialize/sync Sitecore structure and content.

However the JSS Development Workflow is still in effect when creating a new item.

How can I deactivate this workflow completely?

3 Answers 3

8

To disable workflow entirely across your JSS templates and existing items, you can use the following bit of Sitecore PowerShell to clear the Default workflow on templates, and the Workflow and Workflow state on content items.

Note that this script totally removes all workflow from the referenced content and template paths, so use with care if you have other existing workflows you wish to preserve.

$contentRoot = Get-Item "master:\content\jss-react-sample"
$templatesRoot = Get-Item "master:\templates\Project\jss-react-sample"

# Disable workflow on the templates
$templatesCount = 0
$templatesRoot | Get-ChildItem -Recurse | ? { $_.Name -eq "__Standard Values" } | % {
    $_.Editing.BeginEdit()
    $_.Fields["__Default workflow"].Reset()
    $_.Editing.EndEdit() | out-null
    $templatesCount++
}
Write-Host "Updated $templatesCount templates"

# Remove workflow on existing content
$contentCount = 0
$contentRoot | Get-ChildItem -Recurse | % {
    $_.Editing.BeginEdit()
    $_.Fields["__Workflow"].Reset()
    $_.Fields["__Workflow state"].Reset()
    $_.Editing.EndEdit() | out-null
    $contentCount++
}
Write-Host "Updated $contentCount content items"
3
  • Thanks for the reply. Checked the script on my local machine and can now create a new Item that does not have the Default JSS Workflow when I check the workflow fields. However, is still see the warning message explaining that the Item will be overridden in the next Jss Import. Will deleting the JSS Development Workflow remove this message, or is there another way to do this?
    – Jan-Pieter
    Commented Apr 2, 2019 at 14:07
  • @Jan-Pieter That warning is independent from the workflow, since even after removing the workflow (actually, especially after removing) the import could still overwrite those items. You can remove it by ensuring that the import user (sitecore\JssImport by default) does not have write access to the app/site item tree. Commented Apr 2, 2019 at 14:46
  • @techphoria414 I cannot find this user on our prod environment. Still getting this warning message. Can there be some other reason for this?
    – NewbieHere
    Commented Jan 28, 2020 at 5:26
5

The simplest way will be just removing the Default workflow from the existing template's standard value and update/enable it back when needed. Also the new templates needs to be created without any default workflow and setup later when needed.

Note - If you have lot of existing templates, can try execute a power-shell command to set/revoke default workflow.

enter image description here

Anyways you are planning to go with Sitecore first and Unicorn for content sync, so nothing will overwrite your template changes until you revert back.

As an additional note the default workflow for jss app is set in the \Website\App_Config\Sitecore\JavaScriptServices\Sitecore.JavaScriptServices.Apps.config file,

Anyways no update required here in your case, as you are planning for Sitecore first with Unicorn.

1

In order to disable this warning (assuming you have already disabled the JSS Development Workflow as others have answered):

enter image description here

I have found this is triggered by the pipeline, defined in \App_Config\Sitecore\JavaScriptServices\Sitecore.JavaScriptServices.AppServices.config

<getContentEditorWarnings>
  <processor type="Sitecore.JavaScriptServices.AppServices.Pipelines.GetContentEditorWarnings.ShowJssNotifications, Sitecore.JavaScriptServices.AppServices" resolve="true" />
</getContentEditorWarnings>

Either you can disable/remove the pipeline via config patch, or, by decompiling the code and reviewing its logic I can see that this is checking for Write access for the sitecore\jssimport user

    using (new UserSwitcher(User.FromName(appConfiguration.ImportUser, isAuthenticated: false)))
    {
        if (contextItem.Access.CanWrite())
        {
            args.Notifications.Add(new Notification
            {
                Title = Translate.Text("The current item is allowed to be overwritten during next import."),
                Description = Translate.Text("If this is unexpected, please move the item to Content Mode workflow state or protect it against overwrite using JSS Import security presets.")
            });
        }
    }

The way to do this is to remove this security setting from your JSS site (sitecore > content > yourSiteName)

enter image description here

If you do this, be aware that JssImport user inherits from sitecore\Author role (among others) so if you have granted Write permission for this then you would have to Deny Write permission for JssImport.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.