Pages

13 July, 2022

Sitecore XP - Content author cannot cancel or pick a winner in A/B Test created by another content author

In Sitecore XP, to cancel or pick a winner (variation) in A/B test, a content test owner who created the test or an administrator can do it. In case if there is an another non-admin content author (who is not the content test owner) who wants to pick a winner, content author should be part of a Sitecore role - sitecore\Analytics Advanced Testing.

In our project, we had a project specific Sitecore role called sitecore\Base Content Editor role. Then based on content author location, we have created Site specific roles (example: Site Role 1) inheriting the Base Content Editor.  


Base Content Editor role has content authoring specific Sitecore roles and also sitecore\Analytics Advanced Testing. Content authors are added to Site Roles. A content author user (User 1) created an A/B tested and started it. It ran for few weeks and another content author user (User 2) with the same access tried to pick a winner based on the test results but the button was greyed out. 


Observations:

  1. If we add Analytics Advanced Testing role to the second content author user directly and not as an inherited role, then pick a winner button was enabled and user was able to click the button. 

    It seems that hasRole processor in <canCancelTest> pipeline is checking only the top level role of the user and not the inherited roles. Ideally Sitecore should be checking the top level user roles and also the inherited roles. Sitecore Support has added this to their tracker (Reference number: 542108) and they will change the behavior of the hasRole processor.

  2. If we add the custom Site Roles to the <canCancelTest> pipeline -> HasRole processor, the second content author was able to click the pick a winner button. 

You can choose the option 2 if we have any site specific roles so that the second content authors can cancel or pick a winner of a test created by content author one. 

07 July, 2022

Sitecore CLI Installation Failure or Wrong Version Installed

Recently developers are facing issues when installing Sitecore CLI. Or it may install version 5.0.16 which is not released officially. 

PS C:\Project\Working\cli1> dotnet tool install --add-source=https://sitecore.myget.org/F/sc-packages/api/v3/index.json sitecore.cli
You can invoke the tool from this directory using the following commands: 'dotnet tool run sitecore' or 'dotnet sitecore'.
Tool 'sitecore.cli' (version '5.0.16') was successfully installed. Entry is added to the manifest file C:\Project\Working\cli1\.config\dotnet-tools.json.

error NU1202: Package sitecore.cli 5.0.16 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1) / any. Package sitecore.cli 5.0.16 supports: net6.0 (.NETCoreApp,Version=v6.0) / any
The tool package could not be restored.
Tool 'sitecore.cli' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

Sitecore Official release version for Sitecore CLI as of July 7th 2022 is 4.2.1. Unofficially Sitecore published Sitecore CLI 5.0 as they are testing the new features. 

Anyone who installs Sitecore CLI without a specific version will get v5.0. Add version parameter to install the specific version to avoid this issue. 

dotnet tool install --add-source=https://sitecore.myget.org/F/sc-packages/api/v3/index.json sitecore.cli --version 4.2.1

05 July, 2022

Sitecore Media Upload Dialog - Duplicate Item Name Validation Error

In Sitecore Media Library, multiple items with same name is denied by default. This is configured by the setting AllowDuplicateItemNamesOnSameLevel. Default it is set to false to restrict the duplication.

If a content author uploads a media item in a folder which has an item with same name, then Upload File dialog will throw an error. "An error occured while uploading a file. The reason may be that the file does not exist or the path is wrong.". This is not a meaningful error to the content authors. 


1984 14:44:04 ERROR Could not save posted file: Related Items.png
Exception: Sitecore.Exceptions.DuplicateItemNameException
Message: The item name "Related Items" is already defined on this level.
Source: Sitecore.Kernel
   at Sitecore.Data.Items.ItemUtil.AssertDuplicateItemName(Item destinationItem, Item sourceItem, String name)
   at Sitecore.Data.Items.ItemUtil.AssertItemName(Item destinationItem, Item sourceItem, String name)
   at Sitecore.Data.Items.Item.Add(String name, TemplateID templateID)
   at Sitecore.Resources.Media.MediaCreator.CreateItem(String itemPath, String filePath, MediaCreatorOptions options)
   at Sitecore.Resources.Media.MediaCreator.AttachStreamToMediaItem(Stream stream, String itemPath, String fileName, MediaCreatorOptions options)
   at Sitecore.Resources.Media.MediaCreator.CreateFromStream(Stream stream, String filePath, MediaCreatorOptions options)
   at Sitecore.Resources.Media.MediaUploader.UploadToDatabase(List`1 list)
   at Sitecore.Resources.Media.MediaUploader.Upload()
   at Sitecore.Pipelines.Upload.Save.Process(UploadArgs args)
In order to provide content author with meaningful error message, you can overwrite the Upload Media dialog and render a meaning error message. sitecore.shell.Applications.Media.UploadMedia.UploadMediaPage2 Dialog has to be modified. Sample code is placed in this repo







blockquote { margin: 0; } blockquote p { padding: 15px; background: #eee; border-radius: 5px; } blockquote p::before { content: '\201C'; } blockquote p::after { content: '\201D'; }