Monday, May 31, 2021

Sitecore 10 -SCS -An exception occurred while processing the request. ---> Sitecore.Exceptions.DuplicateItemNameException

 This is a very common issue while working on the Sitecore content serialization, 


sitecore ser validate --fix command didn't resolve the issue, so what's next?

We have to remove that item manually, You can see item name in the error message, As example below

[master] Applying changes...

GraphQL.ExecutionError: An exception occurred while processing the request. ---> Sitecore.Exceptions.DuplicateItemNameException: 

The item name "Your Item Name" is already defined on this level.

   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.set_Name(String value)

   at Sitecore.Services.GraphQL.Serialization.Mutations.SerializationCommands.RenameItemCommand.Execute(SerializationCommandData command, String dataModel)

   at Sitecore.Services.GraphQL.Serialization.Mutations.SerializationCommands.CommandExtensions.TryExecute(IEnumerable`1 commands, IList`1& results)

   at Sitecore.Services.GraphQL.Serialization.Mutations.ExecuteSerializationCommandsMutation.Resolve(ResolveFieldContext context)

   --- End of inner exception stack trace ---

GraphQL.ExecutionError: Cannot return null for non-null type. Field: name, Type: String!.

   at GraphQL.Execution.ExecutionStrategy.ValidateNodeResult(ExecutionContext context, ExecutionNode node)

   at GraphQL.Execution.ExecutionStrategy.<ExecuteNodeAsync>d__7.MoveNext()


Note - Try to remove just first parent node of the content and push the serialization again, that has resolve my issue.

Monday, May 24, 2021

Git PowerShell command to delete all local branch.

Git PowerShell command to delete all local branch.

git checkout master; git branch -D @(git branch | select-string -NotMatch "master" | Foreach {$_.Line.Trim()})


Reference - com/JSeed/5d022570ea52ee09a8f43913214496f1

Tuesday, May 11, 2021

Network nat is ambiguous (2 matches found on name) - fix

Recently, I got this issue during the development, the error was 

network nat is ambiguous (2 matches found on the name)


I deleted all the containers and restarted the docker 


Restarting and removing the network container didn't help me -


I tried all possible ways but it didn't work, Finally did below steps to fix the issue

https://github.com/microsoft/DockerTools/issues/89#issuecomment-405562498

Please make sure to restart your system :) 


Monday, May 10, 2021

Sitecore 10 - SCS (Sitecore content Serialization) - please remove the overlapping includes or use rules to exclude the item.

Recently, I got the below error during the content serialization, Here is how I fixed it.

Error Details

 [master] [Batch 1] [Preprocess] [Fetch created item data] The item /sitecore/content/Site/XXX/Presentation/Page Designs/Dev (bfece879-7ae8-4588-874f-430a7000b9b0) is contained multiple modules, please remove the overlapping includes or use rules to exclude the item.

I ran the sitecore ser validate --fix and that didn't resolve the issue.


I check the confirmation and found a similar path was used to create the child item and it's basically a duplicate item.

Added Previously -

"path": "/Presentation/Partial Designs", "scope": "ItemAndDescendants", "allowedPushOperations": "CreateOnly"

Recently Added -

{

                "name": "XXX",

                "path": "/sitecore/content/Tenant/Site/Presentation/Partial Designs/XXX"

            }

To fix it, I have to remove either the new one or the old configuration.




Sitecore 10 - SXA - Tips to setup the page design.

Recently, I was doing a setup for the SXA template and wanted to set up a default page design, I had created the page design and able to see the content but when I check the template, I couldn't see it in the dropdown (Standard field).

I did the reindex and checked the log couldn't see any error, for the workaround I enabled the raw value and added the GUID in the selected field to make it work,

Note - This is not the recommended way, We need to identify the root cause of raising the support ticket, but this is just a workaround, for the time being, I will post the actual root cause.

Template structure -


Content 





Sunday, May 9, 2021

Sitecore 10 - SXA - Composite component - Show the data source field value

 Recently, I created and extend a few composite components like Accordion, tab etc, in one of the requirement, I wanted to use the data source field name for the data (analytics attribute) and for the deep linking, Just wanted to share as it's a simple and easy way to get the value.

CustomAccordionModel.AccordionName = this?.Rendering?.DataSourceItem?[Templates.CustomAccordion.Fields.AccordionName];


Usually, we use rendering parameters to set the additional settings and use it in the repository like below.

Rendering.Parameters.ParseInt(Constants.RenderingParameters.CustomAccordion.FiendName); like we can add field and setting as a rendering parameters or composite child item.


 @foreach (var composite in Model.CompositeItems)

                    {

var accordionItemName = composite.Value[Templates.CustomAccordionItem.Fields.AccordionItemName] ?? "";

}

Conclusion - While working on SXA component it's important to understand three options and places to get the item value.

1.  Component level settings (Rendering.Parameters) - will be used in experience editor, in that case, we need to add the field in the data source item and those fields will be accessible with the below code


Rendering.Parameters.ParseInt(Constants.RenderingParameters.CustomAccordion.FiendName);


2.  Composite Child Item additional fields -  Mostly we use this value in the view to show the data or add some conditions etc.

 @foreach (var composite in Model.CompositeItems)

                    {

var accordionItemName = composite.Value[Templates.CustomAccordionItem.Fields.AccordionItemName] ?? "";

}

3. Composite Item (Main data source) - Some time you would need that value to set the data attribute for the analytics or accessibility point of view.

CustomAccordionModel.AccordionName = this?.Rendering?.DataSourceItem?[Templates.CustomAccordion.Fields.AccordionName];


Ref - https://www.w3.org/TR/wai-aria-practices-1.1/examples/accordion/accordion.html

Monday, May 3, 2021

Sitecore 10 - How to fix orphan item with Sitecore content serialization.

 It can happen when you do manual checking and miss some references.


Sitecore Error message -

Detected that item /Account (dae40400-3820-475d-a16b-ea28bb8446b7) in destination should be moved to /sitecore/content/XXXXXComponents/Header and Navigation/Navigation/Data/Account Navigation/Account, but /Account was not a path included in any serialized subtree being synced. This could indicate that a Sitecore item has been moved from its deserialized location, or that an item has been moved between two serialized subtrees where only one of the subtrees is part of the current operation. To resolve this either the serialized item should be removed (i.e. with 'pull'), or the database item moved back to the serialized tree.


Fix - Have to remove those items manually from the Serialization folder

Sunday, May 2, 2021

Sitecore 10 - Model does not exist in the current context

 Recently, I got this issue while working on the view (Razor), I was not able to see the references of model and Html helper in the view, Example below




I followed a few blogs and post https://stackoverflow.com/questions/24147846/system-web-webpages-html-htmlhelper-does-not-contain-a-definition-for-sitecor and  https://sitecore.stackexchange.com/questions/520/c-mvc-razor-view-htmlhelper-does-not-contain-a-definition-for-sitecore

and copied the web. config file from the vanilla system and it resolved the issue.

Please make sure to copy the web. config from the Vanila view folder not from the root folder .

Path for the reference -