Tuesday, April 30, 2024

Sitecore Search - Crawler error and fix

During the crawler setup, I got below error 



Fix, some pages missing OG details, make sure your meta data is placed properly on all pages


    • Missing Fields: type
    • Required Fields: type, id
Some pages are showing 404, so published those pages

If you check the attributes, these two are by default mandatory field in the schema



to fix this issue, provide the fix type value in Search or add the attribute selector to get the value from the pages.

Tuesday, April 16, 2024

Troubleshooting Sitecore XM Cloud: Deployment Process Halted with Status Code 409 - Project and Environment Already in Deployment.

Lately, during the construction and deployment of the UAT environment, all builds were stuck in the queue and failed to respond. Despite numerous attempts to delete the builds, the issue persisted.



After posting about the problem in the Slack channel, we were unable to find a definitive solution. Consequently, we raised a Sitecore ticket, seeking assistance with the issue.


Slack Posted Question - I'm currently encountering an issue with deploying a build on the UAT environment. Despite waiting for several hours, the build remains stuck in the queue.


After canceling the build and attempting to restart the environment, it' showing an message  that the build is still running and it's preventing the restart.

Now, every build is getting queued up. Do we have any options available to resolve this issue? the same branch was successfully deployed to a different environment (Dev) without any issues.

I would greatly appreciate it if anyone who has experienced a similar problem could share their suggestions.

Console error was 

{

    "title": "Not Found",

    "status": 404,

    "detail": "Deployment entity not existing for deploymentId XXXXXXXXXX",

    "traceId": "XXXXXXXXXXXXXXXXXX"

}


There was an issue with our service connection, due to which environment was wrongfully marked as having a running deployment, got fix now.

Slack Reference -  Slack Conversation Link


Wednesday, February 7, 2024

Sitecore XM Cloud - Fixing URL Redirections in Next.js on Vercel Using vercel.json

When URLs don't redirect correctly, it can be frustrating. Recently, we faced this challenge in our Next.js app on Vercel. Let's walk through how we tackled it.

Our URLs containing spaces or special characters weren't redirecting properly on Vercel. This glitch disrupted our users' flow and needed fixing ASAP.

Exploring Solutions:

At first, we tried a JavaScript-based approach within our app code. It worked fine locally but didn't cut it on Vercel.

Leveraging vercel.json:

Next, we discovered Vercel's powerful vercel.json file. With it, we could define redirect rules to map old URLs to new ones. Simple yet effective!

Crafting the Solution:

We created a vercel.json file with rewrite rules. These rules told Vercel how to handle URLs with spaces or special characters, ensuring they redirected correctly.


Sample vercel.json Code:


{
    "rewrites": [
      {        
        "source": "/(.*)%20(.*)",
        "destination": "/$1-$2"
      },
      {        
        "source": "/(.*)\\s(.*)",
        "destination": "/$1-$2"
      }
    ]
  }
 

Deployment and Validation:

After updating the vercel.json file, we deployed our Next.js app on Vercel. Through testing, we confirmed that our URLs now redirected smoothly, no more hiccups!

Conclusion:

In our journey to fix URL redirection issues, we learned the power of vercel.json. By leveraging its capabilities, we resolved our problem and improved our users' experience. It's a reminder that sometimes, simple solutions are the best.

Tuesday, January 2, 2024

Unveiling Sitecore XM Cloud: Error Encountered Post-Publishing Visual Studio Project

 Recently, I got below error while publishing the VS project 



Microsoft (R) Visual C# Compiler version 4.8.3761.0

for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.



This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version.


Fix - I have to delete the VS publishing profile and that fixed the issue.




Sunday, December 3, 2023

Resolving "Valid value for rootItemId not provided" Error in Sitecore XP and Nex.jss Setup


Recenlty, I encountered an error that might be familiar to Sitecore XP and Nex.jss users: "Error: Valid value for rootItemId not provided and failed to auto-resolve app root item." In this blog post, I'll share the solution to this issue, providing step-by-step guidance to address it.



The Error: Upon initiating the client setup, the mentioned error surfaced, indicating a missing or incorrectly configured rootItemId. The solution to this problem lies within the Sitecore environment, specifically in the site group settings.

Solution Steps: To resolve the "Valid value for rootItemId not provided" error, follow these steps:

Access Sitecore CMS:

Log in to your Sitecore Content Management System.

Navigate to Site Group Settings.

Go to the following location in the Content Editor: /sitecore/content/MainSite/Site1/Settings/Site Grouping/Site1.

Locate the app name field:

Once you're on the designated path, look for the field related to the application name. This is crucial for resolving the error.

Update the app name:

Provide the correct name for the app in the designated field. Ensure accuracy and consistency with your application settings.

Save Changes:

After updating the app name, save the changes in Sitecore. This step is essential for the changes to take effect.

Rebuild and deploy:

Depending on your setup, consider rebuilding and redeploying your Sitecore and Nex.js applications to ensure that the changes are reflected.

Verify the fix:

Finally, revisit your application and confirm that the error no longer persists. If configured correctly, the rootItemId issue should be resolved.

Conclusion: By following the outlined steps, you can successfully address the "Valid value for rootItemId not provided" error in Sitecore XP and Nex.jss setups. Keep in mind the importance of accurate app naming in the Site Group Settings, as this directly impacts the resolution of the issue.

Saturday, November 18, 2023

TypeError: Cannot read properties of undefined (reading 'parents')

 



During the deployment of a Next.js application, you may encounter the error 'TypeError: Cannot read properties of undefined (reading 'parents')'. This error indicates that the code is attempting to access a property named 'parents' on an object that is undefined.

Cause of the Error

The error typically arises when the code expects an object to have a 'parents' property, but the object is either undefined or does not have that property. This can happen due to various reasons, such as:

  • Incorrect or missing layout path: The layout path might be incorrect, leading to the inability to load the required components and resulting in undefined objects.

  • Data fetching issues: If the code relies on data fetched from an API or other sources, any issues in fetching or processing the data can lead to undefined objects.

  • Component rendering errors: Errors in component rendering can cause unexpected behaviour and result in undefined objects.

Resolving the issue

To resolve this error, you can follow these steps:

  1. Verify Layout Path: Double-check the layout path to ensure it is correct and points to the intended location of the layout component.

  2. Inspect Data Fetching: Check if the data fetching process is working correctly and that the fetched data is being properly parsed and assigned to the appropriate variables.

  3. Review Component Rendering: Review the component rendering logic to ensure that the components are being rendered correctly and that there are no errors that might be causing unexpected behaviour.

Alternative Approaches

In addition to the above steps, you can also consider alternative approaches to address the error:

  • Conditional Rendering: Implement conditional rendering to check if the object is undefined before attempting to access its properties.

  • Default Values: Provide default values for the object's properties to prevent undefined values from causing errors.

  • Error Handling: Implement robust error handling to gracefully handle undefined objects and prevent the application from crashing.

Conclusion

The 'TypeError: Cannot read properties of undefined (reading 'parents')' error can be resolved by carefully examining the layout path, data fetching, and component rendering logic. 

In my case I did two things, One is updated the Layout path and publish the items and second is Implemented conditional rendering considerig the experience editor mode.

Wednesday, November 15, 2023

Mastering Environment Management in Sitecore XM Cloud: A Comprehensive Guide

Sitecore XM Cloud empowers organizations to craft personalized and engaging digital experiences. Efficiently managing environments and projects is crucial for successful implementation and maintenance. This technical guide delves into the steps involved in deleting an existing environment and creating a new one within Sitecore XM Cloud.

Deleting an Project: A Step-by-Step Guide

Step 1: Navigating to the Control Panel

Log in to the Sitecore XM Cloud Control Panel.

Seamlessly navigate to the project and  "Environments" section.


it's required that first you delete all the environment and after that you will see option to delete the project.

Step 2: Selecting the Environment for Deletion

Within the "Environments" section, identify the environment you intend to delete.

Click on the environment's name to access its details.

Step 3: Initiating Environment Deletion

Locate the "Delete" option within the environment details.

A confirmation dialog will appear. Confirm the deletion by following the on-screen instructions.    


Option to delete



Creating a New Environment: A Step-by-Step Guide

After deleting an environment or when establishing a new project, creating a new environment is the next step.

I'm going to use the Sitecore CL to setup the project and enviroment, here are some command details

XM Cloud projects are like collections of Sitecore XM environments, allowing you to organize and manage your Sitecore solutions effectively. Embarking on an XM Cloud project is an exciting venture, and I'm here to guide you through the initial steps.

Fist, you need to relogin using the CLI, otherwise you will get below errror 




Step 1: Creating Your XM Cloud Project

Navigate to your project's working directory using the command line.

Execute the following command to create a new XM Cloud project:

dotnet sitecore cloud project create --name <project-name>

Replace <project-name> with a descriptive name for your project.

For instance, to create a project named "MyXMCloudProject," use the following command:

dotnet sitecore cloud project create --name MyXMCloudProject

Note the assigned project ID for future reference.

Tip: To retrieve the project ID at any time, use the following command:


dotnet sitecore cloud project list

Step 2: Creating an Environment for Your XM Cloud Project

Within your project's working directory, open a command-line window.

Execute the following command to create an environment for your project:

dotnet sitecore cloud environment create --name <name> --project-id <project-id>

Replace <name> with a meaningful name for your environment.

Replace <project-id> with the project ID you noted earlier.

For example, to create an environment named "staging" for your project with ID "6btMioN1QDVjSUvQkklkVR," use the following command:



dotnet sitecore cloud environment create --name staging --project-id 6btMioN1QDVjSUvQkklkVR

Note the assigned environment ID for future reference.

Tip: To retrieve the environment ID at any time, use the following command:

dotnet sitecore cloud environment list --project-id <project-id>

Step 3: Deploying Your Solution to the XM Cloud Environment

Within your project's working directory, open a command-line window.

Execute the following command to initiate the deployment process:

dotnet sitecore cloud deployment create --environment-id <environment-id> --upload

Replace <environment-id> with the environment ID you noted earlier.

Example 

dotnet sitecore cloud deployment create --environment-id abc

This command creates a deployment that kicks off immediately and includes all the code in your current working directory.

Tip: To retrieve the environment ID, use the following command:



dotnet sitecore cloud environment list --project-id <project-id>

Once the deployment completes, the command line will display a URL pointing to your XM Cloud Sitecore CM instance. Open the link to access your Sitecore XM Cloud CM instance.

To access the Sitecore Launchpad, append /sitecore to the root URL of the instance in your browser's address bar.

Congratulations! You've successfully created an XM Cloud project, established an environment, and deployed your solution. Now, you're ready to embark on your Sitecore development journey.