output
stringlengths 34
25.7k
| instruction
stringlengths 81
31k
| input
stringclasses 1
value |
---|---|---|
No, by default Solr will not return all versions of the item. But it's not really Solr related, it's how Sitecore publishing and web database works.
When you publish an item, it only published the latest publishable version of the item is being transferred to the web database, and all the other versions of that item (if they were in the web database when publishing started) will be removed from web database. And that latest publishable item will be indexed in Solr.
But from what I understood, what you need is only to show the latest version of some items, ordered by date. And that your content authors will prepare those new versions and publish them at some point. With that in mind, I think it's all doable and you don't need any customization for that. Just make sure that:
your content authors will prepare multiple versions of items and set the Publishing Restrictions of items to only publish given version from certain date ( https://doc.sitecore.com/xp/en/users/103/sitecore-experience-platform/set-up-publishing-restrictions-for-an-item.html )
code will order items using Sitecore Content Search Api by date and render returned results appropriately.
| Item versions to create by date
We have requirement to show some text content (rich text field) based on revision date updated (date field). Latest updated content (sorted by date in descending) will be shown at the top . So content authoring will like , next month when I want to create new content with different date , he/she will be interested in creating new content and publish, so the webpage should take care of showing new record at the top and old ones at the bottom in descending order
Maximum number of records could go up to 50-80 in a folder.
Trying to find best possible solution to create these kind of items in sitecore.
Note- These data will be be fetched by search API(using solr, Sitecore version 10.3) currently identified solution is:
Maintain same item version history to show different records
Question
1)-can solr can return all versions of an item and
2)any other drawback of this aproach)
Thank you!
| |
To patch any version of Sitecore Identity server, you should make use of the sitecoreruntime folder.
Within that folder, create a subfolder with the name of the environment you are working on (i.e. UAT). Then create an an environment variable called SITECORE_Environment and give it the same value (i.e. UAT).
Within that sub folder, you can then place an exact copy of sitecorehost.xml and override any settings specific to your chosen environment.
A typical distribution may then be deployed with multiple sub folders within the sitecoreruntime folder. The system will check the value stored within Sitecore_Environment variable and patch over the environment specific settings from within the relevant folder.
i.e.
C:\inetpub\wwwroot\your-identity-server\sitecoreruntime\UAT\sitecorehost.xml
UPDATE
If you look at the examples provided in the first link below, they use one less SITECORE in their environment variable then you have in the question.
I just tested setting the environment variables below to "Debug" and can see they have successfully patched the settings:
SITECORE_Logging__Serilog__MinimumLevel__Default
SITECORE_Logging:Serilog:MinimumLevel:Default
Therefore, please try again but use either of these in your situation:
SITECORE_Logging__ApplicationInsights__InstrumentationKey
SITECORE_Logging:ApplicationInsights:InstrumentationKey
Further information here:
https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-manager/configuration.html
https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-manager/runtime-configuration.html
| How can I patch Sitecore Identity Server 7 App Insights Instrumentation Key?
I have managed to patch settings like CertThumbprint and the ConnectionString by setting environment variables in the following style:
Sitecore_Sitecore__IdentityServer__CertificateThumbprint
Sitecore_Sitecore__IdentityServer__SitecoreMemberShipOptions__ConnectionString
I have tried to follow the same pattern for the InstrumentationKey setting but I'm not seeing the logs appear in AppInsights - if I manually override the default value in sitecorehost.xml, then they do appear.
| |
Yes, we have implemented Google ReCAPTCHA on Sitecore Forms 10.3 Headless with Next.js. The steps involved are similar to creating a custom field in Sitecore Forms for MVC implementation, as outlined in the official Sitecore documentation here.
However, there is a crucial difference in the approach. In the MVC implementation, custom form elements have a "razor view" (.cshtml file) that defines how they are rendered. For the JSS (Headless) approach, this HTML part needs to be reimplemented, as Sitecore returns only configuration, not HTML structure. The .cshtml file cannot be directly reused for the JSS approach.
To associate your form element with JSX, you use a defaultFieldFactory. Here's an example of how to create a custom field factory for Google ReCAPTCHA in React with the @sitecore-jss/sitecore-jss-react-forms library:
// CustomFieldFactory.js
import React, { RefObject, useEffect, useRef, useState } from 'react';
import ReCAPTCHA from 'react-google-recaptcha';
import {
createDefaultFieldFactory,
FieldTypes,
ValueFieldProps,
} from '@sitecore-jss/sitecore-jss-react-forms';
export const AllFieldTypes = {
...FieldTypes,
GoogleRecaptcha: '{id here from path : /sitecore/system/Settings/Forms/Field Types/Security/Google Recaptcha}',
};
const CustomFieldFactory = createDefaultFieldFactory();
type ReCaptchaProps = ReCAPTCHA & {
captcha: {
parentElement: {
querySelector: (arg0: string) => Element | null;
};
};
};
CustomFieldFactory.setComponent(AllFieldTypes.GoogleRecaptcha, ({ field }: ValueFieldProps) => {
const [errorMessage, setErrorMessage] = useState<boolean>(false);
const recaptcha: RefObject<ReCaptchaProps> = useRef(null);
const handleRecaptchaChange = (value: string) => {
value?.length > 0 && setErrorMessage(false);
};
useEffect(() => {
let formButton;
if (recaptcha?.current != null) {
formButton = recaptcha?.current?.captcha?.parentElement?.querySelector('[type = "submit"]');
}
formButton &&
formButton?.addEventListener('click', (e) => {
const captchaValue = recaptcha?.current?.getValue();
if (captchaValue?.length === 0) {
setErrorMessage(true);
recaptcha?.current?.reset();
e.preventDefault();
}
});
}, [recaptcha]);
return (
<>
<ReCAPTCHA
sitekey={field?.model?.publicKey as string}
onChange={handleRecaptchaChange}
ref={recaptcha}
/>
{errorMessage && <span>{field?.model?.errorMessage as string}</span>}
</>
);
});
export default CustomFieldFactory;
Once you have created the custom field factory, pass it to your form rendering component, as shown in the following example:
// Forms.js
import { Form } from '@sitecore-jss/sitecore-jss-react-forms';
import React from 'react';
import { withRouter, NextRouter } from 'next/router';
import { sitecoreApiKey } from '../temp/config';
import CustomFieldFactory from './CustomFieldFactory';
const Forms = ({ fields, router }: { fields: never; router: NextRouter }) => {
return (
<div className="apply-now-container" id="apply-now-container">
<div className="container">
<Form
form={fields}
sitecoreApiHost={' '}
sitecoreApiKey={sitecoreApiKey}
onRedirect={(url) => router.push(url)}
fieldFactory={CustomFieldFactory}
/>
</div>
</div>
);
};
export default withRouter(Forms);
This custom field factory is designed to help the headless form package load the Google ReCAPTCHA schema.
You can refer to this blog for complete implementation - https://sitecorehelphouse.wordpress.com/2023/12/22/step-by-step-guide-to-integrating-google-recaptcha-in-sitecore-forms-for-headless-applications/
You can see this documentation from Sitecore JSS as well:
https://github.com/Sitecore/jss/blob/release/19.0.0/docs/data/routes/docs/techniques/forms/en.md
| Implementing Google Recaptcha on Sitecore Forms 10.3 Headless with React JS
could someone please explain or share the documentation or articles for implementing Google Recaptcha on Sitecore Forms 10.3 Headless with React JS? I haven't found any useful articles related to it. For your information, I've been using the "@sitecore-jss/sitecore-jss-react-forms" library.
Thanks
| |
Sitecore allows you to specify a locked relationship between parent and child items that are stored in a bucket, so it lends credence to this idea being acceptable:
You just need to be sure that this is configured properly and ensure that any possible item that may be created as a nested item within the bucket has this property set to true (where applicable).
When it comes to adding advanced functionality in buckets, whether a feature is good practice or not comes down to two factors:
Does it produce quirky side effects?
Can content authors easily understand / navigate / edit? It is crucial to understand your client.
It's worth noting that by default, bucketed items are actually hidden from view, and in its simplest implementation, bucket items are meant to be added from the top level (bucket) item, and bucketed items are meant to be found via search rather than manually drilling down. That said, when bucket functionality was first released, the concept of nested datasource items was less prevalent.
As a final point, think hard about whether a bucket is truly necessary the first place. Good old manual folder creation is easy for content authors to understand. So long as you don't have thousands of child items under a single node, the manual approach is rock solid.
| Is it good practice to use bucket items with Children?
I need to be able to build a navigation component, using items that are under a bucket.
There is a requirement in which the navigation would require different levels of nesting.
I was wondering if it's feasible or good to practice to allow editors to nest the items in a bucket, so to create something like the below:
Or would it be better to use a field defined on the page template itself to just link to the respective pages and hierarchy from there, without tampering with the current structure?
| |
SXA doesn't support spaces in Site names. Here is a link to documentation:
https://doc.sitecore.com/xp/en/developers/sxa/103/sitecore-experience-accelerator/the-sxa-site-definition-fields.html
When you choose a name for the website, you must avoid using characters that are invalid for the website cookies. Therefore, do not use control characters, spaces (" "), semicolons, or commas in your website names.
I remember issues with publishing, there are also issues with built in Sitecore tools like Experience Analytics, caused by spaces in SXA cookies storing site name after opening Experience Editor.
There is no "0-code" fix that would help you with FA and SXA site with space in its name, so you can either;
make your site compliant with SXA guidelines by removing spaces from site names
or you start writing workarounds for all the Sitecore and SXA functionalities and after you fix one thing, you realize that still some 3 others don't work as expected.
My choice would be obvious: remove any illegal characters from SXA site names.
| Federated Authentication with Space in Site Name
I have several SXA sites with spaces in the site name. When enabling federated login for a site containing a space in the name I get the following error on the redirect.
"Site from query string was not found: My%20Website"
It's obviously encoding the space. Renaming all sites without a space would involve code changes. Is it possible to have a space in the name? If so, what is the workaround?
Thanks
| |
What you can do is replacing default Glass.Mapper.Sc.GlassHtml with your own implementation that will always use true for outputHeightWidth parameter like:
public class CustomGlassHtml : Glass.Mapper.Sc.GlassHtml
{
public CustomGlassHtml(ISitecoreService sitecoreService) : base(sitecoreService)
{
}
public override string RenderImage<T>(T model, Expression<Func<T, object>> field, object parameters = null, bool isEditable = false, bool outputHeightWidth = false, string imgElementTemplate = "<img src={2}{0}{2} {1}/>")
{
return base.RenderImage(model, field, parameters, isEditable, true, imgElementTemplate);
}
}
Now you need to create your own IGlassHtmlFactory implementation like:
public class CustomGlassHtmlFactory : IGlassHtmlFactory
{
public CustomGlassHtmlFactory(IDependencyResolver dependencyResolver)
{
}
public IGlassHtml GetGlassHtml(ISitecoreService sitecoreService)
{
return new CustomGlassHtml(sitecoreService);
}
}
and finally register your own factory in Glass dependency resolver. There are multiple options depending on Sitecore version. In Sitecore 10 you should be able to add processor to glassMapper.createResolver pipeline:
<glassMapper.createResolver help="Processors should derive from Glass.Mapper.Sc.Pipelines.CreateResolver.CreateResolverProcessor">
<!-- Add any changes to the standard resolver here. -->
</glassMapper.createResolver>
Something like this should do the trick:
public class SetCustomFactory : CreateResolverProcessor
{
public override void Process(CreateResolverPipelineArgs args)
{
args.DependencyResolver.GlassHtmlFactory = new CustomGlassHtmlFactory(args.DependencyResolver);
}
}
| Glassmapper Set outputHeightWidth = true by default
I have a requirement where I need to display the image height and width tags on images. This is also a performance ranking factor for Google Lighthouse. By default, this is set to false in Glassmapper as follows:
//
// Summary:
// Renders an image allowing simple page editor support
//
// Parameters:
// model:
// The model that contains the image field
//
// field:
// A lambda expression to the image field, should be of type Glass.Mapper.Sc.Fields.Image
//
// parameters:
// Image parameters, e.g. width, height
//
// isEditable:
// Indicates if the field should be editable
//
// outputHeightWidth:
// Indicates if the height and width attributes should be outputted when rendering
// the image
//
// Type parameters:
// T:
// The model type
public virtual HtmlString RenderImage<T>(T model, Expression<Func<T, object>> field, object parameters = null, bool isEditable = false, bool outputHeightWidth = false)
{
return new HtmlString(GlassHtml.RenderImage(model, field, parameters, isEditable, outputHeightWidth));
}
While I can add the following to each of my image renderings, I would prefer to default this to true for all images so none get missed (we have a lot of image renderings across so many pages and need to maximize our SEO):
@Html.Glass().RenderImage(panel.GlassItem, x => x.My_Image, isEditable: true, outputHeightWidth: true )
I have a foundational project for Glassmapper, but am unsure where and how is the best place to default this setting to true (ex. App_Start > GlassMapperScCustom.cs)
| |
create a new folder under /sitecore/system/Settings/Forms/Meta Data/CSS Class Options and call it Form
add new items for every color you want to use for the background colors under Form folder using /sitecore/templates/System/Forms/Meta Data/CSS Class Option template and for the value field use e.g. form-blue-background, 'form-grey-background`, etc.:
select /sitecore/system/Settings/Forms/Field Types/Form item and in Css Class Autocomplete Options field select /sitecore/system/Settings/Forms/Meta Data/CSS Class Options/Form folder created earlier:
now when your content authors start typing first name of the CSS class in CSS Class field of Styling section in Forms Editor, there will be auto-suggested option for all the available styles that you define:
Remember to add proper styling in your CSS files for all the background options.
EDIT
In Sitecore 9.2 there is no option for CSS Class Options metadata, but your content authors can still add any CSS class to the Styling section in Form Editor:
There is no way to add auto-suggestion for the classes so you need to inform them about all the possible options for form backgrounds.
| Make background color of sitecore form configurable from sitecore
I am using Sitecore MVC form in rendering and the requirement is to make user capable of changing form back ground.
Need suggestions to achieve it.
Can we use rendering param in Sitecore form?
Can we create a custom MVC form? I created but it seems to be not working.
Or any other ways to achieve it ??
Version: Sitecore 9.2
| |
There's a bit of messing about to be done for external "shared" project folders owing to the fact that the file paths are relative to the current project root initially and then when it generates the src\temp\componentBuilder.ts file the paths need to be relative to the location of the that file in the temp folder. As a result this is one way to do it (be interested to hear if anyone has a more elegant way..) We're just replacing the relative paths in the output array returned to be the value we need inserted into the src\temp\componentBuilder.ts file.
| What's the best way to register components into the component builder from other directories?
I'm working on a monorepo solution which would have a set of Shared components one level above the site folder.
I'm looking at updating scripts\generate-component-builder\plugins\components.ts per the documentation and if I specify ../shared/component it gets registered to the site src\temp\componentBuilder.ts, however when building the site, the file can't be found as it is on a different directory.
| |
Could you please check the below steps might help you?
You go to the page where this component consists of the member.
Then click on the "..." as shown below.
Then click on Edit.
Then go to the DateTime Field. Something like below and click on the settings icon.
Then you will get a pop-up for Format and other settings where you can change the format as below.
The output will look like below.
For more details check here. Hope this will help.
Note: This works for DateTime and DateTime offset.
| Content Hub Date Time Field not displaying Time option
I am using Sitecore Content Hub and in one of the Content Types we have defined the Field type Datetime Field:
However, last two days I observed that while selecting the date the time option does not appear. Previously date and time options were there with a calendar and clock.
Time options are missing. Anyone facing the same issue or any idea, please.
| |
Found the issue, turns out that it was that docker was not adding solr (or any of the container names) to it's DNS... so when it was trying to iwr against http://solr:8983/*, it could not resolve solr. Found this out as mssql-init was also having some issue resolving the mssql container.
Not sure if this is due to the version of docker I was using, but I reinstalled an older version (4.26.1) that the other devs were successfully using and it works fine.
shrugs
| My Solr health check during docker compose up is failing in my local xm cloud instance
I am having an issue with starting my XM Cloud Local Docker instance, using the up.ps1 script.
It looks to be stopping specifically at this health check:
test: ["CMD", "powershell", "-command", "try { $$statusCode = (iwr
http://solr:8983/solr/admin/cores?action=STATUS
-UseBasicParsing).StatusCode; if ($$statusCode -eq 200) { exit 0 } else { exit 1} } catch { exit 1 }"]
Manually checking this, while it is still in the waiting stage shows that this should work, as it is returning a 200 response, as per the image shown below:
But after 120 seconds, it's showing that the health check failed:
Hoping someone else has encountered this issue too, and might have a resolution for me.
Bridgette
| |
You need to use different tag names for each of the indexes. Otherwise Sitecore will merge them into one.
Use:
<customIndex1>customindex_1</customIndex1>
<customIndex2>customindex_2</customIndex2>
<customIndex3>customindex_3</customIndex3>
<customIndex4>customindex_4</customIndex4>
| Configuring Sitecore Publishing Service to update multiple custom indexes
I'm currently trying to set up the Sitecore Publishing Service on an instance of Sitecore 10.1 (the page for all of the downloads and instructions is here)
Without the publishing service, we rely on 4 custom indexes to be updated when an item is published.
The "Publishing Module Installation and Configuration Guide" states the following about custom indexes (apologies for the formatting):
1.3.3 Configuring Cache Clearing and Indexing
The Sitecore.Publishing.Service.Delivery.config is responsible for raising events to
rebuild the search indexes and clear data caches on the target instance.
If additional custom indexes have been created on a Sitecore instance, each index name must be
added to the publishingservice:searchindex.rebuild setting in the IndexNames section:
<event name="publishingservice:searchindex:rebuild">
<handler
type="Sitecore.Publishing.Service.Delivery.TargetSearchIndexRebuildHandler, Sitecore.Publishing.Service.Delivery" method="RebuildTargetSearchIndex">
<IndexNames hint="list:AddIndex">
<index>sitecore_web_index</index>
<customIndex>MyCustomIndex</customIndex>
</IndexNames>
</handler>
</event>
As such, I have the following in my configuration patch file:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events>
<event name="publishingservice:searchindex:rebuild">
<handler type="Sitecore.Publishing.Service.Delivery.TargetSearchIndexRebuildHandler, Sitecore.Publishing.Service.Delivery" method="RebuildTargetSearchIndex">
<IndexNames hint="list:AddIndex">
<index>sitecore_web_index</index>
<customIndex>customindex_1</customIndex>
<customIndex>customindex_2</customIndex>
<customIndex>customindex_3</customIndex>
<customIndex>customindex_4</customIndex>
</IndexNames>
</handler>
</event>
</events>
</sitecore>
</configuration>
The resulting output when I go to admin/ShowConfig.aspx is the following:
<event name="publishingservice:searchindex:rebuild" patch:source="z.Sitecore.Publishing.Service.Delivery.Patch.config">
<handler type="Sitecore.Publishing.Service.Delivery.TargetSearchIndexRebuildHandler, Sitecore.Publishing.Service.Delivery" method="RebuildTargetSearchIndex" patch:source="z.Sitecore.Publishing.Service.Delivery.Patch.config">
<IndexNames hint="list:AddIndex" patch:source="z.Sitecore.Publishing.Service.Delivery.Patch.config">
<index>sitecore_web_index</index>
<customIndex patch:source="z.Sitecore.Publishing.Service.Delivery.Patch.config">customindex_4</customIndex>
</IndexNames>
</handler>
</event>
So it seems that the custom index declarations are overriding each other until only the last one remains.
How should I alter the configuration files so that all of the custom indexes will be updated when an item is published through the publishing service?
| |
The ONLY recommended answer
The Unicorn configuration files should never be deployed to CD servers. In fact, no part of Unicorn should be deployed to CD servers. Ever.
You need to remove them.
https://github.com/SitecoreUnicorn/Unicorn/issues/398#issuecomment-1250021066
From a technical standpoint, you could alter the original file.
In line 13 of Unicorn.config, change this line:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
To this:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
Now you've enabled the role:require setting. This will solve the error you describe with "role is not specified attribute".
At this point you can change the next line of configuration from:
<sitecore>
to
<sitecore role:require="StandAlone">
Or whatever role you want Unicorn to be active on. DO NOT ENABLE THIS FOR ContentDelivery
Sorry for all the bolded warnings, but I really can't stress this enough. Unicorn is entirely untested for Content Delivery servers and there could be anything from security problems to configuration problems coming from leaving it active in an environment it was never designed for.
For the curious, WHY isn't this set by default?
Because Unicorn tries its best to stick to the "path of least surprise". Unicorn is being used on a lot of projects < 9.x where config roles were introduced.
| Unicorn throws error in content delivery - Could not find base site 'shell' for site 'unicorn'
Sitecore throws below error when loading newly setup instance.
Message: Could not find base site 'shell' for site 'unicorn'. Source: Sitecore.Kernel
It is mentioned in Git that this issue is fixed in this release https://github.com/SitecoreUnicorn/Unicorn/issues/398
But, the version I am using is already having this fix in place.
I am looking for some solution where I can skip this config in CD using role:require = "ContentManagement"
Adding this attribute to Unicorn is throwing other error as role is not specified attribute.
| |
When you create a data template with a droplist field, you are saying that the list should be available to editors to select from. When rendering, you would only render the value selected by the content editor in the head application.
If you want to build a select list that users of the web application would select from you would not use a droplist field in your data template.
You can achieve this by using a multilist or treelist field in your data template and pointing the source property to a list of items that you want to make available for the end users.
A content author would then select which items should be available for the website user. You would have to build your component to read in those values and display that to the user. There is not a way to do this with OOTB components.
| How to provide a select list in the web application
I have a headless rendering based on this template:
Heading: Single-line Text
Description: Single-Line Text
Background: Droplist (source: is an enum folder)
I have a sample item:
The droplist works fine here, but when it comes to rendering this in the tsx component, I am unsure how.
Here is the interface definitions:
interface Fields {
Heading: Field<string>;
Description: Field<string>;
Background: any;
}
type MyProps = {
params: { [key: string]: string };
fields: Fields;
}
I brought set up the props for the background field to be any, to try and see what it would come in as, and it looks like it is coming in as a Field type. I put in a console.log to inspect it:
As can be seen, the value that is coming in is just the selected value that was select in 1, not the list of possible choices. I am unable to build a select/option mapping (which from my understanding is how it is done with sitecore-jss-nextjs).
I've been struggling to find examples of rendering a droplist in xm-cloud or headless (though I am very new to Sitecore, so could just be not knowing the right keywords to search), so hoping someone may be able to assist, even if it is just a link to some sample code I can peruse.
| |
If want to know How many times is each rendering used for a specific website. You can use the below Powershell Script with more information for each rendering.
Open PowerShell ISE (You can found this in /sitecore/shell/ menu, Development Tools, PowerShell ISE
Copy past the script below.
Save as "How many times is each rendering used for a specific website" below Script Library/SPE/Reporting/Content Reports/Reports/Solution Audit
<#
.SYNOPSIS
How many times is each rendering used in your solution?
.NOTES
copy from www.stockpick.nl
#>
Import-Function Render-ReportField
filter IsRendering {
# Look for Controller and View renderings
$renderingIds = @("{2A3E91A0-7987-44B5-AB34-35C2D9DE83B9}","{99F8905D-4A87-4EB8-9F8B-A9BEBFB3ADD6}")
if(($renderingIds -contains $_.TemplateID)) { $_; return }
}
$database = "master"
# Renderings Root
$renderingsRootItem = Get-Item -Path "$($database):{32566F0E-7686-45F1-A12F-D7260BD78BC3}"
$websiteRootItem = Get-Item -Path "$($database):{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}"
$props = @{
Parameters = @(
@{Name="websiteRootItem"; Title="Choose the report root"; Tooltip="Only items from this root will be returned."; }
)
Title = "Items With Component Report"
Description = "Choose the website for the report."
Width = 650
Height = 250
ShowHints = $true
Icon = [regex]::Replace($PSScript.Appearance.Icon, "Office", "OfficeWhite", [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
}
$result = Read-Variable @props
if($result -eq "cancel") {
exit
}
$items = $renderingsRootItem.Axes.GetDescendants() | Initialize-Item | IsRendering
$reportItems = @()
foreach($item in $items) {
$count = 0
$websitecount = 0;
$referrers = Get-ItemReferrer -Item $item
if ($referrers -ne $null) {
$count = $referrers.Count
foreach($ref in $referrers) {
if ($ref.ItemPath.StartsWith($websiteRootItem.ItemPath)) {
$websitecount++
}
}
}
$reportItem = [PSCustomObject]@{
"Icon" = $item."__Icon"
"Name"=$item.Name
"UsageCount"=$count
"WebsiteCount" = $websitecount
"ItemPath" = $item.ItemPath
"TemplateName" = $item.TemplateName
"Controller" = $item.Controller
}
$reportItems += $reportItem
}
$reportProps = @{
Property = @(
"Icon",@{Name="Rendering Name"; Expression={$_.Name}},
@{Name="Total Number of usages"; Expression={$_.UsageCount}},
@{Name="Number of usages below: "+$websiteRootItem.Name.ToString(); Expression={$_.WebsiteCount}},
"ItemPath",
@{Label="Rendering Type"; Expression={$_.TemplateName} },
"Controller"
)
Title = "Custom rendering report"
InfoTitle = "Available Renderings"
InfoDescription = "Count of references for each rendering. Results include only MVC Controller and View renderings.for" + $websiteRootItem.ItemPath.ToString()
}
$reportItems |
Sort-Object WebsiteCount -Descending |
Show-ListView @reportProps
Close-Window
Reference and Credit : https://www.stockpick.nl/english/how-many-times-is-each-rendering-used-for-a-specific-website/
Hope it helps!
| How to find out if a rendering is used in any page
Using Sitecore 10.1.3
We have an existing application which uses both SXA default & custom renderings. There are 100+ renderings and many are not in use any more.
For each rendering, I would check Navigate > Links. For some, I could see the page item reference but some refer to .../Presentation/Available renderings.
And some references are Partial Designs.
So, it is challenging to find out which renderings are actually being used in page items.
Is there a quick way to find out, like a Powershell script.
| |
If you want to check if robots detection works at all, you can execute the following steps:
install an extension like https://chromewebstore.google.com/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg?hl=pl&pli=1 to be able to modify your browser user agent
switch to user agent to use googlebot name (you may need to add it with e.g.Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/W.X.Y.Z Safari/537.36 value)
clear all the cookies from your website
open view-source:https://your.website.com to see the source of your website (without opening your website first).
if robots detection works, you will not see visitor identification javascript in the source:
<script type="text/javascript" src="/layouts/system/VisitorIdentification.js"></script>
| How to verify the Sitecore Robot detection feature?
Are there any scripts/tools to verify the Sitecore Robot detection feature in Sitecore Forms?
If yes, please share some tips.
| |
Workaround 1 - use Windows Server 2022 for the host machine
I managed to eventually find there is an open issue here for this problem.
... the problem exists only when running Windows Server image on Windows
Desktop host machine.
This is the case for me where the host machine is Windows 11 Pro and the image is mcr.microsoft.com/windows/nanoserver:ltsc2022 with process isolation enabled.
So it seems the only available workaround to the symlink issue is to use Windows Server 2022 for the host machine.
Workaround 2 - don't use docker anymore for the rendering host
Just don't use docker anymore for the rendering host, and run npm run start:connected from the host machine.
You can still get Pages editor working locally by pointing it to to <host ip address>:3000. There is also a way to use host.docker.internal instead of the IP address.
| XM Cloud with NPM workspaces on local Docker throws "Error: EPERM: operation not permitted, symlink"
I'm using the standard monorepo and making it multi-site with each site having its own npm workspace, and then a shared code npm workspace.
This is all working fine, it deploys to XM Cloud and runs successfully.
The only issue is the local Docker environment. The rendering container fails to run with Error: EPERM: operation not permitted, symlink 'C:\app\packages\ui' -> 'C:\app\node_modules\@aceik-demo\ui'
If I remove the npm install from the dockerfile and run npm install first on the host machine, then on startup it gives an error saying it can't find @aceik-demo\ui. It looks like this is because it doesn't know about these important symlinks in the container.
I've tried making sure the container is using ContainerAdministrator, but it makes no difference.
| |
You can create a function to see the full path of Items. The function can be used in stored procedures or ad-hoc queries for reporting purposes.
USE [Sitecore_Master]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[GetItemPath]
(
@ParentID UNIQUEIDENTIFIER,
@CurrentPath VARCHAR(MAX)
)
RETURNS VARCHAR(MAX)
AS
BEGIN
DECLARE @NewParentID UNIQUEIDENTIFIER,
@EmptyGUID UNIQUEIDENTIFIER
SELECT @EmptyGUID = CAST(CAST(0 AS BINARY) AS UNIQUEIDENTIFIER)
SELECT @CurrentPath = '/' + i.Name + @CurrentPath,
@NewParentID = i.ParentID
FROM Items AS i
WHERE i.ID = @ParentID
if(@NewParentID != @EmptyGUID)
BEGIN
SELECT @CurrentPath = dbo.GetItemPath(@NewParentID, @CurrentPath)
END
RETURN @CurrentPath
END
Here’s an example of the function in use:
SELECT i.ID, i.Name, dbo.GetItemPath(i.ID, '') AS FullPath
FROM Items AS i
Reference: SQL Querying Sitecore Database Directly: Get FullPath of Item
Hope it helps!
| Which database table contains the Sitecore item path?
I thought of query the Sitecore master/web database and get the item path information to display it in dashboard instead reading the data from Sitecore content editor.
Could I get some thoughts on here?
| |
As described in the official documentation you will need to change the Elevation Action from Password to Confirm.
https://doc.sitecorepowershell.com/security
| Unable to use SPE with Azure AD login
When I login into the Sitecore CMS using Azure AD, and open SPE, It prompts for the password.
I tried entering the Azure AD password but it is not accepted.
I have also enabled this \App_Config\Include\Spe\Spe.IdentityServer.config, but no luck.
Checked this article, but could not figure out what needs to be done for the fix.
This is Sitecore 10.1.3 on Managed Cloud.
| |
Sitecore monitors this API, its a SaaS product provided by Sitecore as the vendor who is responsible for all monitoring and has an SLA with the customer for up time and scalability. There is no need for external monitoring as only Sitecore have access to the resources that provide the API.
Currently the content token is the only option. Do not expose that content token to the browser if you want to keep your content behind any kind of login.
Experience Edge has a rate limit of 80 requests per second, anything above this will result in failed requests until the limit is reset in the next second. This only applies to uncached responses, if your GQL request is already in the cache, it will not count. Edge is built on a globally scaled edge network and designed to scale to your needs. But you will need to make sure your web application makes proper use of caching to avoid issues with going over the rate limit.
| Queries on Content Hub Experience Edge API on Delivery Platform
We have integrated Experience Edge with our Content Hub and currently have exposed the GraphQL API on the delivery platform. We are currently authorizing requests via delivery API. I am seeking some inputs on the below queries:
Does Sitecore have any provision to monitor and analyse all incoming traffic (eg. per API request count, per key request count, response time, etc.) via the experience edge delivery platform?
Is there any other way to authorize GQL requests like OAuth other than delivery/preview API keys?
Are there any traffic limitations for GQL APIs exposed via Experience Edge? And if there is an increase in traffic what will be the behavior and how Sitecore will handle this?
My requirement for the above queries is to:
Monitor and analyze all incoming API requests on the Experience Edge platform. Also if we have any other way to access this matrix.
We want to make it more secure by using OAuth or any other authorization mechanism?
Our target audience is huge we want to know the behavior of APIs when we have large incoming traffic.
Please share if anyone has insight on it.
| |
At the time of writing, XM Cloud Deploy does not support private npm packages or git submodules. If you are using the github/Azure DevOps integration, this will not work.
You can make the submodule workaround work by using the CLI to create deployments. You would need to create your deploy pipeline to checkout your main repo, then pull in your submodules, finally create a deployment with the --upload command. This will upload all the source code in the folder to XM Cloud Deploy and start the build/deploy process.
dotnet sitecore cloud deployment create --environment-id <id> --upload
Its important to note, you can only do this if you created the Project and Environment by using the CLI. If the Project was created by the UI and linked to a repo integration, it will only allow integration deployments.
You will also need to make sure that your pvt-components folder is not in your .gitignore, the deployment create command with upload, obeys your .gitignore settings.
| React component import is not resolved in Sitecore deployment environment
I am using next/jss starter kit and trying to add a React component inside Sitecore navbar (src/sxastarter/src/components/Navigation.tsx) and push it to Sitecore.
The component I am trying to add is taken from another repository that acts as pvt npm package. It is added to the nextjs project as a gitsubmodule.
The issue I am facing is that the project build fails with a type error in Sitecore pipeline though it builds successfully in the local env.
Type error: Cannot find module '@ui-design/dashboard' or its corresponding type declarations.
I have configured a custom Sitecore pipeline to install .gitsubmodules to a folder called pvt-components inside sxa starter and the repository is cloned successfully. I have dependencies in the nextjs project that are installed from the submodule and they get installed successfully. So I guess there is no issue cloning the submodule to Sitecore deploy environment.
Is there any reason that component cannot find its type or module in the Sitecore deploy environment?
Cant I directly push a react component like this to Sitecore or am I missing any steps?
There is no way to reproduce this type error on local project since it builds successfully in local and shows the added component in Sitecore navbar.
tsconfig.json
"paths": {
"components/*": ["src/components/*"],
"lib/*": ["src/lib/*"],
"temp/*": ["src/temp/*"],
"assets/*": ["src/assets/*"],
"graphql-types": ["node_modules/@types/graphql-let/__generated__/__types__"],
"@ui-design/*": ["node_modules/@ui-design/*"],
"@ui-design/legacy-components/*": ["node_modules/@ui-design/legacy-components/*"]
}
package.json dependencies
"@ui-design/custom-bootstrap": "file:./pvt-components/packages/custom-bootstrap",
"@dtp-vic/dashboard": "file:./pvt-components/packages/dashboard",
this is the component that I am adding to Navigation.tsx
'use client';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { AuthPanelContainer } from '@ui-design/dashboard';
export default function MyAuth() {
const router = useRouter();
return (
<>
<AuthPanelContainer
onBuyRequest={handleBuyRequest}
onRegister={handleRegister}
onToUnlock={handleUnlock}
onUpdatePasswordSuccess={handleUpdatePasswordSuccess}
>
//...some logic
</AuthPanelContainer>
</div>
</>
);
}
Error points to this import in the above component
import { AuthPanelContainer } from '@ui-design/dashboard';
| |
Updated Answer
Clearing the MediaCache folder and restarting the site fixed the issue permanently; a restart was not enough. Clearly there were files in the media cache that were causing the getMediaStream threads to run out of memory. The exact cause is not cleared, but presumably it was due to corrupt files.
Original Answer
Restarting the App Service resolved the issue. My guess is that this was a byproduct of a recent Azure outage.
Below is a chart of the app service memory usage over the period and after the restart. You can see the memory usage drop down right after the reset, but the memory usage never appeared to be anywhere near the limit (7GB) during the period of the issue occurring, so it is still unclear as to why this exception was being thrown.
| Media field attachment preview image is full-sized instead of thumbnail-sized
I have content management sites (Sitecore 10.2.1) in 3 different environments. On my non-production sites, my image media library items show reasonably sized attachment previews such that I can easily view the whole image:
Note the small image and small network requests. If I download the image, it is the full size (10.3 MB), which is good.
However, on my production site, the attachment preview image is huge:
In both cases, the item does have dimensions specified:
I am not aware of any relevant configuration differences between the different environments.
I inspected the network requests and found that the same URL is being called across the environments:
/sitecore/shell/Applications/-/media/28a55f89466648d99cd911ac7aa001f4.ashx?bc=white&db=master&h=128&mw=640&thn=1&vs=1&ts=10c8c8d6-9b4a-4874-ae02-c444286c9ade&udi=1
When I navigate directly to it on my non-production sites, the h=128&mw=640 params are honored -- however, my production site returns the full sized image.
Therefore, the issue can be partially narrowed down to a difference in handling of: /sitecore/shell/Applications/-/media/28a55f89466648d99cd911ac7aa001f4.ashx?h=128&mw=640
Looking at the logs, I do see this error:
Could not run the 'getMediaStream' pipeline for '/sitecore/media library/....'. Original media data will be used.
With the stack trace:
Exception: System.OutOfMemoryException
Message: Out of memory.
Source: System.Drawing
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
at Sitecore.ImageLib.Resizer.ResizeAny(Bitmap image, Size imageSize, Size frameSize, Color frameColor, Boolean preserveResolution, InterpolationMode interpolationMode, CompositingMode compositingMode, PixelOffsetMode pixelOffsetMode)
at Sitecore.ImageLib.Resizer.Resize(Bitmap bitmap, ResizeOptions options, ImageFormat format, InterpolationMode interpolationMode)
at Sitecore.Resources.Media.ImageEffectsResize.ResizeImageStream(Stream inputStream, TransformationOptions options, ImageFormat outputFormat)
at Sitecore.Resources.Media.ImageEffects.TransformImageStream(Stream inputStream, TransformationOptions options, ImageFormat outputFormat)
at Sitecore.Resources.Media.ThumbnailGenerator.GetImageStream(Stream inputStream, TransformationOptions options)
at Sitecore.Resources.Media.ImageThumbnailGenerator.GetStream(MediaData mediaData, TransformationOptions options)
at Sitecore.Resources.Media.MediaData.GetThumbnailStream(TransformationOptions options)
at Sitecore.Resources.Media.ThumbnailProcessor.Process(GetMediaStreamPipelineArgs args)
at (Object , Object )
at Sitecore.Pipelines.PipelineMethod.Invoke(Object argument)
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args)
at Sitecore.Resources.Media.Media.GetStreamFromPipeline(MediaOptions options, Boolean& canBeCached)
There are similar questions to this on SSE, but not with this particular stack trace.
| |
Check the "Base Url" Field in your "Email Configuration" in Content Tree
and change it to your domain
| Images and Links in EXM message are not coming when receiving the e-mail
I am working on Sitecore 10.3 and created automated message from EXM, I added custom html in Body Text component and added image and link from Sitecore media.
but when I sent the email,
, I received the e-mail without images and links, not coming in the correct way.
when I checked the src of image it came like that
https://ci3.googleusercontent.com/meips/ADKq_NaMGesUffd5sBGiB_nbhufndys23P2XfY713Gnt4Qs3GWyIGoxar-CSyfQTccu7E6yqH4Azl4wu_jHRw8CxMx4qvyf21xtgwHlfFdUP-AR8pgTaee6NCcTEI7dmk4md8oyBWuKaNh9PoSR-c-o=s0-d-e1-ft#http://your.host/-/media/Project/Murabba/murabba-site/images/Email-Template/image_1.png
I do not know why it is coming like that, any idea how to resolve this??
| |
Finally, I found the 100% solution for that. Sharing it here to benefit the community:
IWebMClient _mclient = MClientFactory.CreateMClient(endpoint, oauth);
var uploadSource = new LocalUploadSource("C:\SomeFolder\New.png");
Dictionary<string, object> action = new Dictionary<string, object>();
action.Add("AssetId", 109956);
var request = new UploadRequest(uploadSource, "AssetUploadConfiguration", "NewAlternativeFile");
request.ActionParameters = action;
var response = await _mclient.Uploads.UploadAsync(request).ConfigureAwait(false);
In the upload request, there's a third parameter called "supported action." Depending on your requirement:
To create a completely new asset, use "NewAsset.".
To create a new version, use "NewMainFile.".
To replace the image, use "NewAlternativeFile.".
| Upload a new version of an asset using the WebClient SDK in Content Hub
Is it possible to generate/upload a new version of an asset using the WebClient SDK in Content Hub? I am aware that this can be done through the Portal, but I need to perform this task programmatically.
| |
I ended up resolving this by using a Scriban variant with the promos. With IGenerateScribanContextProcessor I was able to point each action link to the appropriate site. Works great.
| General Link Field Reuse with Multisite
I have a Sitecore 10 SXA multisite setup that uses delegated areas. Each delegated page (item) contains several promos with datasources set to the main site. Within these promos we have internal links to various delegated items shared to all sites. I want these promos locked down but would like to have the internal general link field in the promo not link back to the main site. Instead, it should be aware of site context and stay within the current site.
My original thought was some $site token in the general link field but I'm assuming there is a better method. I imagine this is a common multisite question.
Any help would be appreciated.
Thanks!
| |
While not intuitive, you can do this with the Regular Expression validator. Add one to your field.
Use the expression ^({[^}]+}\|?){2,5}$
(2,5) is thw boundaries you mention in your question.
Source: https://mskutta.github.io/2019/08/20/sitecore-how-to-limit-the-number-of-items-selected-in-a-treelist-field/
| How can I define a limit on number of items added to a Multi-list
I have a Template that contains a multi-list, and the client wants said multi-list to have a limit on the count of items added to that multilist: minimum of 2, maximum of 5.
Is there an OOTB validation rule that can do this? I've looked through the samples, and can't see anything that seems relevant.
I've not been able to find online documentation that actually documents what is available in the Sitecore.Data.Validators (though that might be my unfamiliarity with sitecore documentation) to see if I can write my own, so if anyone has a link to the documentation that covers what is in the Sitecore.Data.Validators.* or Sitecore.Kernel that are in the Data/Type field for the sample validation rules would be appreciated too.
| |
Can you try adding below code while retrieving field value.
using (new LanguageFallbackFieldSwitcher(true))
{
// Retrieving Item's Field Value
}
Also make sure the database do not contains any entry for the item in the fields table. You can check for the corresponding entry in the db by executing below SQL Query:
Select * from {{db_name.FieldsTable}}
Where ItemId = '{{item_id}}' and Language = '{{language}}' and FieldId = '{{fieldid}}'
In case the entry is there you need to delete that and check that again. This is because fallback value is returned only when value in the field is not changed.
| How programmatically get field value from fallback language when field level fallback is enabled?
I'm using sitecore 9.3. I set en as fallback language for en-IE. I have enabled field level fallback on the template level.
I have item with 2 fields. For en-IE:
Text_1 - is empty, so value from en is displayed
Text_2 - has value "Text_2 en-IE"
How can I get fallback value for Text_1 field? All solutions I have found are related to item level fallback and involve using Sitecore.Data.Items.Item.GetFallbackItem() to get whole fallback item, however in my case I have only one field with fallback value and above method returns null.
I have tried different combinations of field.GetValue(bool allowStandardValue, bool allowDefaultValue, bool allowFallbackValue, bool allowInheritValue, bool allowInnerValue):
Language lang = Language.Parse("en-IE");
Item item_ = master.GetItem("DE0A175C-AB8B-4521-874D-10C7F3F6943C", lang);
Field text_1_field = item_.Fields["Text_1"];
bool contains_fallback_value = text_1_field.ContainsFallbackValue;
string value = text_1_field.Value;
string value_1 = text_1_field.GetValue(false, false, true);
string value_2 = text_1_field.GetValue(false, false, true, false, false);
string value_3 = text_1_field.GetValue(true, true, true, true);
but I haven't got correct field value:
contains_fallback_value equals false
value equals ""
value_1 equals null
value_2 equals null
value_3 equals ""
Shouldn't value store value from fallback language (i.e. Text) and contains_fallback_value be true? How can I get fallback value for this field?
| |
I don't think it is possible using token because token will allow us to dynamically add values to fields, according to the item that is being created by the Content Author.
So you can create your own ItemSave handler which will change this field for particular item templates.
You can follow below link for more details.
How to change Sitecore field value based on another field(s)
Hope this helps.
| How to update a link field when a drop list item is selected?
Is there a way to dynamically change the value of a Template field in Sitecore based on other template field selected value.
For example, let's say we have a template that has the following fields:
State (Type drop list)
Link (Link)
Expectation is : when to state field is selected , update the Link field value with selected state name as query string parameter
I understand On ItemSave is one way, wanted to know is it possible using token/field
| |
As you want to run this as scheduled job, so you can ensure that there is a sufficient gap between the last run and the new run. You could perhaps run it once a day. So, I feel that there is no need to check the index state.
You should have a null check in place for indexName. If the indexName is empty or null, you should return.
You could add try-catch clause so that if the jobs fails you get to know about it by checking the logs.
You should also include additional logging comments like "Starting indexing for {indexName}" at the start of the function and "Finished indexing for {indexName}" at the end.
| What to check before rebuilding a Sitecore index via scheduled task?
I'm trying to do something that I don't see a lot of descriptions of.
For our installation of Sitecore, we have a special index, for managing pictures via a service called "Digizuite".
This index breaks once in a while, and then needs to be reindexed. We have not been able to determine why, but maybe we will at some point, who knows.
But, in order to fix the issue more acutely, we decided to create a command in Sitecore that we could start via a Sitecore scheduled task, and then reindex it once a day.
So, I have created a command that points to a method in the code, and then is started via a scheduled task.
The code I have written so far looks like this:
public void Execute()
{
RebuildIndexes("dfs_assets_master_index");
RebuildIndexes("dfs_assets_web_index");
}
private void RebuildIndexes(string indexName)
{
var index = GetIndex(indexName);
var indexstate = index.IndexingState;
if (indexstate == IndexingState.Started)
{
index.Rebuild();
indexstate = index.IndexingState;
}
}
Where I basically check the state of the index, and if it is not already running, then I run rebuild on it.
The only check I have implemented for avoiding double-indexing is to check whether the index is not stopped or paused. But could I implement some other important checks? such as checking the last index of the rebuild?
| |
You can try this solution
let button = document.querySelector('button[type="submit"]')
button.addEventListener("click" , function () {
button.disabled = true;
})
| How to Disable Submit Button After Click in Sitecore Forms?
I'm working with Sitecore 10.1 and facing a challenge with Sitecore forms. I want to disable the submit button right after it's clicked. I've attempted some script solutions but haven't found a reliable way that integrates smoothly with Sitecore's form handling.
Below script I tried but it didn't work
<script type="text/javascript">
// Disables submit button and changes its appearance only if the form is valid
$(document).ready(function() {
$('form').each(function() {
var form = $(this); // Current form in the loop
form.on('submit', function(e) {
// Check if the form is valid
if(form.valid()) {
var submitButton = form.find('input[type="submit"], button[type="submit"]');
if (!submitButton.prop('disabled')) {
submitButton.prop('disabled', true).val('Submitting...').addClass('disabled-button');
}
}
});
});
});
</script>
Has anyone successfully implemented a solution for this? Any suggestions would be appreciated.
| |
Its known issue, method not found: Microsoft.Extensions.Caching.Memory
can you please try the following and verify the same:
Open your Sitecore website folder and navigate to {sitecore-instance-directory}\App_Config\Sitecore\Marketing.Xdb.ReferenceData.Client
rename Sitecore.Xdb.ReferenceData.ClientCache.config to Sitecore.Xdb.ReferenceData.ClientCache.config.disabled
| Sitecore Content Hub: Method not found: 'Void Microsoft.Extensions.Caching.Memory Error
I have installed Sitecore 10.3.1 and now I am trying to Install Sitecore Connect for Content Hub on-prem as mentioned in this document https://doc.sitecore.com/xp/en/developers/connect-for-ch/51/connect-for-content-hub/install-sitecore-connect-for-content-hub-on-prem.html.
I run this script:
<path where you extracted the SCCH SIF installation script>\deploy.ps1 `
-ScchWdpPackage “<path of SCCH module installation package downloaded>” `
-InstanceName “<Sitecore instance name>” `
-InstanceUrl “<Sitecore instance url>” `
-SitecoreAdminUser “<Sitecore admin user name>” `
-SitecoreAdminPass “<Sitecore admin password>” `
-SqlInstanceName “<Sitecore SQL Database prefix name>” `
-SqlUser “<SQL server user name>” `
-SqlPass “<SQL server password>” `
-SqlServerName “<SQL server name>” `
-SkipDatabaseInstallation “<true or false for skip database installation>”
But after running this, I am getting below error:
Method not found: 'Void Microsoft.Extensions.Caching.Memory.MemoryCache..ctor(Microsoft.Extensions.Options.IOptions`1<Microsoft.Extensions.Caching.Memory.MemoryCacheOptions>)'.
Please suggest.
| |
Hi @lahiru Lanka Rathnayka,
As you see in below screenshot
You are able to drag and drop because its available in Sitecore, but corresponding named component on react site is missing.
And that also means that components like "FeaasWrapper","BYOCWrapper" are not created by us (developers), but those are features of XM Cloud to be able to work with FeaaS and BYOC features.
In your code repo those components are missing, so you will need to update your repo in order to have those components flow into your repo and then your XM Cloud instance will be pointing to latest rendering host and then you should be able to get it working.
I have had same issues, but after having a latest code, it just works.
| Steps to follow from Sitecore side when following BYOC (Bring your Own Component) Approach
I am following the documentation to bring and register a react component and reuse it in Sitecore component editor.
https://doc.sitecore.com/xmc/en/developers/jss/latest/jss-xmc/walkthrough--registering-an-external-react-component.html
I was able to register the component successfully in the Sitecore
And it shows in the component section as well
But once I drag and drop it to the editor it gives me this error
What are the exact steps that I need to follow from the Sitecore side in order to BYOC approach in sitecore.
I have already created a data Template.I need to know the next steps(Like creating a rendering)in order to make this work properly. Not sure where to create rendering for BYOC. And not sure about this BYOC wrapper and FEaaS wrapper.
| |
In the config file you mentioned there is a setting called Unicorn.MaxItemsToQueue
<!--
Max number of items that will be processed individually by the publishing code.
If number of changed items in a sync operation goes > MaxItemsToQueue, a system Smart Publish will be executed instead
Set this value to 0 if you always want Smart Publish to happen. Set it to something silly (like 1000000) if you never want Smart Publish to happen
-->
<setting name="Unicorn.MaxItemsToQueue" value="1000" />
It means that if you sync more items than value of the setting, it will trigger smart publish of the whole site instead of publishing only those items which were synced.
Just change the setting to 1000000 and it will stop auto-publishing the whole site and instead it will only publish what is synced.
And it you don't want auto publish to happen at all, you can disable the file, empty the file and leave only <sitecore> node in it or remove TriggerAutoPublishSyncedItems processor - whatever is the easiest for you.
| Unicorn publishes all the items under the root Sitecore item after unicorn sync
When we run the unicorn sync for limited items based on the unicorn configuration's predicate rule then in SPS we noticed that it is publishing all the items under top root sitecore {11111111-1111-1111-1111-111111111111}
The auto publish happens after every unicorn sync and we can not disable that unicorn.autopublish.config.
Environment: SXA with Sitecore 10.3 based on containers
Unicorn Version: 3.0
| |
The issue appears to have resolved on its own approximately 10 minutes after reinstalling the module. The cause it not clear, however, caching appears to be a likely factor.
| PowerShell commands not running in ISE
I am trying to run a simple command on my CM 10.2 instance running on an App Service:
Write-Host "test"
However, the script never seems to run, even if I set a breakpoint and debug. This works fine on other environments. The working environment and the broken environment have the same bin files. The SPE config files also appear to be the same. Nothing has changed as far as I know.
I am an administrator and I have elevated permissions, and I have reproduced the issue with other admin users.
There is nothing notable in the browser console logs on either environment; they are the same.
I can see the POST request to /sitecore/shell/Applications/PowerShell/PowerShellIse?sc_bw=1&xmlcontrol=PowerShellIse returning a 500 error, with these messages in the logs:
Exception of type 'System.Web.HttpUnhandledException' was thrown. Exception has been thrown by the target of an invocation. The type initializer for 'Spe.Core.Host.ScriptSession' threw an exception. Cannot load Windows PowerShell snap-in Microsoft.PowerShell.Utility because of the following error: Could not load file or assembly 'Microsoft.PowerShell.Commands' or one of its dependencies. The system cannot find the file specified.
System.Web.HttpUnhandledException:
at System.Web.UI.Page.HandleError (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.UI.Page.ProcessRequestMain (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.UI.Page.ProcessRequest (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.UI.Page.ProcessRequest (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.UI.Page.ProcessRequestWithNoAssert (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.UI.Page.ProcessRequest (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at ASP.sitecore_shell_default_aspx.ProcessRequest (App_Web_vqiwhdbc, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
at System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.HttpApplication.ExecuteStepImpl (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.HttpApplication.ExecuteStep (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
Inner exception System.Reflection.TargetInvocationException handled at System.Web.UI.Page.HandleError:
at System.RuntimeMethodHandle.InvokeMethod (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Reflection.RuntimeMethodInfo.Invoke (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at Sitecore.Reflection.ReflectionUtil.InvokeMethod (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Pipelines.Processor.Invoke (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Nexus.Pipelines.NexusPipelineApi.Resume (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Pipelines.Pipeline.Resume (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Pipelines.Pipeline.DoStart (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Pipelines.Pipeline.Start (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Web.UI.Sheer.ClientPage.RunPipelines (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Web.UI.Sheer.ClientPage.OnPreRender (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at System.Web.UI.Control.PreRenderRecursiveInternal (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.UI.Page.ProcessRequestMain (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
Inner exception System.TypeInitializationException handled at System.RuntimeMethodHandle.InvokeMethod:
at Spe.Core.Host.ScriptSession..ctor (Spe, Version=6.3.0.17327, Culture=neutral, PublicKeyToken=null)
at Spe.Core.Host.ScriptSessionManager.GetSession (Spe, Version=6.3.0.17327, Culture=neutral, PublicKeyToken=null)
at Spe.Client.Applications.PowerShellIse.JobExecuteScript (Spe, Version=6.3.0.17327, Culture=neutral, PublicKeyToken=null)
at Spe.Client.Applications.PowerShellIse.JobExecuteSelection (Spe, Version=6.3.0.17327, Culture=neutral, PublicKeyToken=null)
Inner exception System.Management.Automation.Runspaces.PSSnapInException handled at Spe.Core.Host.ScriptSession..ctor:
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadMshSnapinAssembly (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIn (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIns (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadConsole (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.PowerShell.get_Runspace (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Spe.Core.Host.ScriptSession..cctor (Spe, Version=6.3.0.17327, Culture=neutral, PublicKeyToken=null)
The same issue happens even when performing actions in the ISE that shouldn't require elevation, such as pressing the "About" button:
A restart of the App Service did not fix the issue.
I performed a reinstallation of the SPE module, but the issue persists.
| |
Tasks do not run on databases, the tasks run on the Sitecore instance. If your Task Scheduler is enabled on your Content Delivery instance to use your web database, then it will execute any tasks that are configured.
But, Sitecore PowerShell Extensions is not enabled on Content Delivery instances by default. The default configuration only enables SPE for the Standalone, ContentManagement, and XMCloud server roles. So unless you have changed that for your implementation, the tasks integration will not run on a ContentDelivery server role.
| Does powershellScheduler task run on web dbs?
If I publish powershell task scheduler item to target dbs...will the task the task run separately on all dbs?
| |
In the web config you will find security:define configuration which explain security definition:
<!-- SUPPORTED MEMBERSHIP CONFIGURATION FOR CONTENT DELIVERY
Specify the membership configuration that you want this server to use for Content Delivery role. The supported options are:
Sitecore
None
Default value: Sitecore
-->
<add key="security:define" value="Sitecore" />
| "security: "require"="sitecore" in sitecore config
What does "security: "require" in sitecore configuration mean?
<sitecore role:require="Standalone or ContentManagement" security:require="Sitecore">
Does it mean access to sitecore or user should be in Sitecore domain?
| |
Here is an article explaining how to do it https://laubplusco.net/inheriting-renderings-sitecore/
I am briefing the process here, you can find more details with code in articles itself.
Add a placeholder in a rendering/sublayout where you wish to inherit your rendering
Add this placeholder key and rendering id in a Constant class for further usage
Now, you will need to add a processor extending insertRenderings pipeline.
public class AddFallbackRenderings : InsertRenderingsProcessor
{
public override void Process(InsertRenderingsArgs args)
{
Assert.ArgumentNotNull(args, "args");
if (!args.HasRenderings || args.ContextItem == null || Context.Site.DisplayMode == DisplayMode.Edit || InheritRenderingsService.SkipInherit(args.ContextItem))
return;
using (new ProfileSection("Inserting inherited renderings"))
{
if (!args.Renderings.Any(r => r.Placeholder.EndsWith(GetPlaceHolderKey(Constants.Keys.AsideSpotsKey), StringComparison.InvariantCultureIgnoreCase)))
InheritRenderingsService.Inherit(args.ContextItem.Parent, args.Renderings, new ID(Constants.Renderings.AsideSpotsHolderId), Constants.Keys.AsideSpotsKey);
}
}
protected virtual string GetPlaceHolderKey(string splotplaceholderKey)
{
return StringUtil.EnsurePrefix('/', splotplaceholderKey);
}
}
This is a helper class from above article that contains main logic -
internal class InheritRenderingsService
{
internal static void Inherit(Item inheritItem, List<RenderingReference> targetRenderings, ID renderingId, string placeholderKey)
{
if (inheritItem == null || SkipInherit(inheritItem) || inheritItem.Paths.FullPath.Equals(Context.Site.StartPath, StringComparison.InvariantCultureIgnoreCase))
return;
var renderings = inheritItem.Visualization.GetRenderings(Context.Device, true);
if (!renderings.Any(r => r.RenderingID.Equals(renderingId)))
return;
var renderingsToInherit = renderings.Where(r => r.Placeholder.EndsWith(placeholderKey, StringComparison.InvariantCultureIgnoreCase)
|| r.Placeholder.ToLowerInvariant().Contains(string.Concat(placeholderKey, "/").ToLowerInvariant())).ToArray();
if (!renderingsToInherit.Any())
Inherit(inheritItem.Parent, targetRenderings, renderingId, placeholderKey);
else
InsertRenderings(renderingsToInherit, targetRenderings);
}
private static void InsertRenderings(RenderingReference[] renderingsToInherit, List<RenderingReference> targetRenderings)
{
foreach (var renderingReference in renderingsToInherit)
{
renderingReference.Placeholder = CleanPlaceholderName(renderingReference.Placeholder);
}
targetRenderings.InsertRange(targetRenderings.Count, renderingsToInherit);
}
private static string CleanPlaceholderName(string placeholderKey)
{
var placeholderKeys = placeholderKey.Split('/');
return placeholderKeys[placeholderKeys.Length - 1];
}
internal static bool SkipInherit(Item item)
{
var checkBox = new CheckboxField(item.Fields[Constants.Fields.StopSpotInheritance]);
return checkBox == null || checkBox.Checked;
}
}
You can also add a checkbox at Page level to decide where to display inherited rendering (field : StopInheritance)
Now make sure to patch above processor just before Sitecore.Pipelines.InsertRenderings.Processors.EvaluateConditions
< processor type="[NAMESPACE].AddFallbackRenderings, [ASSEMBLY]" />
Also, you can checkout this article from Akshay Sura with similar implementation especially for multisite implementation.
Hope this helps.
| Cascaded/global sublayout components in webforms?
I'm working on a site that is on Sitecore 10 but still uses webforms for the main layout and sublayouts. I'm trying to figure out if it is possible to add a placeholder to the footer where the authors can add or remove sublayouts, and have this content display on EVERY page. In MVC, I would use the Cascade checkbox on the renderings to propagate them to all child pages, but the webforms sublayouts do not have this option. Is this even possible in webforms?
| |
Make sure that in your data template, the Source property of your GeneralLink field is set to query:$linkableHomes
Next make sure that in your /sitecore/Content/<Tenant>/<Site>/Setting item you have the Link Settings option set to All linkable sites or Linkable sites in site collection. By default this will be Itself only
Along with the settings mentioned by Vikrant, that should enable the linkable sites option for you.
Reference: https://doc.sitecore.com/xp/en/developers/sxa/103/sitecore-experience-accelerator/adjust-link-settings-to-enable-cross-site-linking.html
| Insert Link SXA Current Site Item is not displaying
We have maintained SXA multisite with the same tenant. In Settings, we have selected the "Linkable Site with a tenant" option in the Link settings.
Site A
Site B
In Site A, from any CTA link if I try to select the insert link option Site A home and child items are not displaying and in Site B home and child items are displaying.
Why the Site A home and child item is not displaying?
| |
You can follow workflow action to achieve your target.
Please follow below steps to achieve this.
Create a ACTION (using template: /sitecore/templates/System/Workflow/Action) under the Final Workflow State
Under Type String – set the namespace and class name
Then write your custom code according to your requirement, below is sample code for reference you have to update it according to your requirement.
public class PublishedDate
{
private const String publishDate = "_publishDate";
public void Process(WorkflowPipelineArgs args)
{
Assert.ArgumentNotNull(args, "args");
Item item = args.DataItem;
if (args.ProcessorItem!= null)
{
WorkflowState state = item.Database.WorkflowProvider.GetWorkflow(item).GetState(item);
if (state != null && state.FinalState)
{
using (new Sitecore.SecurityModel.SecurityDisabler())
{
using (new EditContext(item, false, false))
{
item.Editing.BeginEdit();
item[publishDate] = Sitecore.DateUtil.ToIsoDate(DateTime.Now);
item.Editing.EndEdit();
}
}
}
}
}
}
Hope this helps you.
| Custom Sitecore Pipeline is not triggering when publishing to Edge
Publishing from Sitecore 10.3 to Edge
I have a custom pipeline that updates the Last Published field with in Sitecore. When I publish to the WEB, it works as expected, but when I publish to Experience Edge, it doesn't update the Sitecore field.
<pipelines>
<publishItem>
<processor patch:after="*[@type='Sitecore.Publishing.Pipelines.PublishItem.PerformAction, Sitecore.Kernel']" type="{Custom}_Sitecore.Pipelines.SetPublishDates, {Custom}"/>
</publishItem>
</pipelines>
Goal: I want to update the first and last published dates when an item has been published.
I would be grateful if you could provide me with any information.
| |
I had the same requirement to create a custom popup on the Sitecore client that looks like this
and here are some general steps you need to follow.
Go to core database and open this path. /sitecore/content/Applications/Content Editor/Ribbons/Chunks
Using insert from template, Create new chunk item (template path : /sitecore/templates/System/Ribbon/Chunk)
Using insert from template, on this chunk, create a Large Button (template path: /sitecore/templates/System/Ribbon/Large Button) and enter details.
Go to the path (/sitecore/content/Applications/Content Editor/Ribbons/Strips). Expand this item and you will see name of existing menus. Choose any one where you want to add this button. In this example I am adding under home item.
Add a new item using the template (i.e. /sitecore/templates/System/Reference)
On the publish folder go to the path (\sitecore\shell\Applications\Content Manager\Dialogs). Create a folder (I have named it “CustomUrl”) and create a file called (CustomUrl.xml). The file is will look like this.
<Script>
function generateUrl()
{
var textFrom = document.getElementById("TextFrom").value;
var textTo = document.getElementById("TextTo").value;
var textDestination = document.getElementById("TextDestination").value;
var url = "?fromtext=" + textFrom + "&totext=" + textTo + "&destination=" + textDestination;
var textUrl = document.getElementById("TextUrl");
textUrl.innerText = url;
}
</Script>
<style>
.scFormDialogFooter{
display: none !important;
}
.scFormDialogFooter .footerOkCancel{
display: none !important;
}
</style>
<div class="scStretch" >
<div class="col2">
<Border Background="transparent" Border="none" GridPanel.VAlign="top" Padding="4px 0px 0px 0px">
<GridPanel Class="scFormTable" CellPadding="2" Columns="2" Width="100%" GridPanel.Height="100%">
<Label For="TextFrom" GridPanel.NoWrap="true">
<Literal Text="From Text:" />
</Label>
<Edit ID="TextFrom" Width="100%" OnChange="generateUrl()"/>
<Label for="TextTo" GridPanel.NoWrap="true">
<Literal Text="To Text:" />
</Label>
<Edit ID="TextTo" Width="100%" OnChange="generateUrl()"/>
<Label for="TextDestination" GridPanel.NoWrap="true">
<Literal Text="Destination Link:" />
</Label>
<Edit ID="TextDestination" Width="100%" OnChange="generateUrl()"/>
<Label for="TextUrl" GridPanel.NoWrap="true">
<Literal Text="Copy Url:" />
</Label>
<Label ID="TextUrl" GridPanel.NoWrap="true">
</Label>
</GridPanel>
</Border>
</div>
</div>
</FormDialog>
Add the code file.
using System;
using Sitecore;
using Sitecore.Shell.Framework.Commands;
using Sitecore.Text;
using Sitecore.Web.UI.Sheer;
namespace YourNameSpace
{
public class CustomUrl: Sitecore.Shell.Framework.Commands.Command
{
public override void Execute(CommandContext context)
{
Sitecore.Context.ClientPage.Start(this, "Run", context.Parameters);
}
protected static void Run(ClientPipelineArgs args)
{
if (!args.IsPostBack)
{
UrlString urlString = new UrlString(UIUtil.GetUri("control:CustomUrl"));
SheerResponse.ShowModalDialog(urlString.ToString(), "800", "300", "", true);
args.WaitForPostBack();
}
else
{
if (args.HasResult)
{
if (Sitecore.Context.Item.Name == "Content Editor")
{
Sitecore.Context.ClientPage.ClientResponse.SetLocation(Sitecore.Links.LinkManager.GetItemUrl(Sitecore.Context.Item));
}
}
}
}
}
}
And add an entry of this new command in the config.
You may refer to my blog for all the details with a graphical representation of this.
https://sbhatiablogs.wordpress.com/2019/07/07/custom-sitecore-menu-button-with-custom-popup-dialog/
Hope this helps.
| Custom popup / Sitecore client
I've requirements to create a custom popup, everytime the author saves an item. The popup has text and two buttons Proceed or Cancel.
Any guidelines on how this can be done?
| |
There is no OOTB API for Sitecore Forms to export data to given form.
There is Forms Client API but it only gives you list of form fields not the values -> https://doc.sitecore.com/xp/en/developers/102/sitecore-experience-manager/work-with-the-form-client-api.html
You can build your own API or extend layout service. Own API is recommended approach.
You can do it similarly to this example:
Create a class which inherits from ApiController
public class FormExportApiController : ApiController
You need to create your method which represent api call :
[System.Web.Http.HttpGet]
[Route("formexport/{formId}")]
public HttpResponseMessage ExportFormEntries(string formId)
You need to register the ApiController
public class Register : IServicesConfigurator
{
public void Configure(IServiceCollection serviceCollection)
{
serviceCollection.Replace(ServiceDescriptor.Transient(typeof(FormExportApiController ),
typeof(FormExportApiController )));
}
}
You need to register in the configuration :
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<services>
<configurator
type="yourNameSpace.ServicesConfigurator,yourNamespace" />
</services>
</sitecore>
</configuration>
To call the api you need to call it in this way
https://yourhostname/formexport/formId
You should check Sitecore.ExperienceForms.Data.SqlServer.SqlFormDataProvider from Sitecore.ExperienceForms.Data.SqlServer assembly located in bin folder on how to get values programatically for your API and incorporate them into your controller / method...
| Is there a rest api to get a list of sitecore forms and export data for given form?
I need to develop a page to show a list of sitecore forms tagged this login user and then allow this user to export data as csv
we do not want user to go to forms and export data there so we need a way to access forms list and forms data without going to xdb, either using library and rest api
| |
Here are a few options.
Show-Output and JavaScript (source)
#... your code here with various helpful Write-Host outputs
Show-Result -Text
# After the Show-Result window is closed, this triggers the redirect
$script = ('window.top.location = "/sitecore/shell/Applications/Content%20Editor?fo=' + $item.ID +'"')
Invoke-JavaScript -Script $script`
I like this approach because:
The user can be shown the result/output of the script.
After closing the result window, the user will automatically be shown the item in the Content Editor and the item tree will remain visible, so it's not too disorienting, despite the page reload.
Show-Application (source)
Show-Application `
-Application "Content Editor" `
-Parameter @{id ="$($item.ID)"; fo="$($item.ID)";
la="$($item.Language.Name)"; vs="$($item.Version.Number)";
sc_content="$($item.Database.Name)"}
The window loads with the content tree view disabled unless the user manually enables it via the ribbon (VIEW --> check "Content tree). However, you can pass the -Modal flag which seems to open the window with the content tree on the left.
| How to open a newly created item in Content Editor via SPE script via the Insert Item integration?
A item is created as part of a SPE script via the Insert Item integration, very similar to the current workflow in Sitecore -- the new item is added as a child of the item we inserted a new item on, except the script performs some additional tasks behind the scenes. What is the best way to allow the user to navigate to it after the script has completed?
The workaround I am doing for now is to show this as part of the script output window:
Write-Host "CLICK to view the new item:
Write-Host "{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}"
The ID is represented as a clickable link, and it will open the item in a new popup window. It does so by performing a network call to /sitecore/shell/Applications/PowerShell/PowerShellIse?sc_bw=1 with a parameter of item:load(id={1D803A5D-42E4-4523-9952-ACFAA9FDBDE3}.
Ideally, I would leverage functionality that mimics the workflow of vanilla Sitecore item insertion; i.e. right click --> insert, then once the script is done, the tree refreshes and shows the new item in real time and focuses on it.
| |
Do you want to add it under the Normal dropdown?
If so first check your RTE Profile, which is being used in the template. based on that.
Change the DB to Core
Navigate to path /sitecore/system/Settings/HTML Editor Profiles/<Your Rich Text Profile From template> change the h2 value and add <h2 class="h2>
| Add class option in rich text editor in h2 tag
I added a class option in the rich text editor in the content tree. The requirement is to add this class in <h2> tag.
But it's adding a class in the <span> tag by default:
The requirement is to add this class in h2 tag. Is there any settings for that ?
| |
After going through your screenshot it seems that you haven't added closing parentheses( ) ).
Try out this query hope this helps
{
search(
fieldsEqual:[{name:"title", value:"Si*" }] rootItem:"/sitecore/content"
) {
results {
items {
item {
id
name
path
url
field(name : "title") {
title: value
}
}
}
totalCount
}
}
}
We by default have 3 endpoints for graphql
Master --> https://<instance>/sitecore/api/graph/items/master
Web --> https://<instance>/sitecore/api/graph/items/web
Edge --> https://{host-name}/sitecore/api/graph/edge?sc_apikey={GUID}
As per your comment you are using edge endpoint and you are using fieldsEqual this doesn't exisit for edge endpoint check the schema for edge endpoint
fieldsEqual exist for master and web endpoint , so now if you try to change your gql endpoint and execute the query you will see the results.
use this endpoint URL and verify if it works--> https://<instance>/sitecore/api/graph/items/master/ui?sc_apikey={}
Refer the screenshots of schema from master and edge endpoint for more clarity.
Master :
Edge :
| Sitecore Graph QL Search getting unknown argument "FieldsEqual"
I am trying to execute search on Graph QL. When I try "FieldsEqual" query, I am getting unknown argument in "Query.Search".
Any help to overcome this issue will be highly appreciated.
SC Version is 10.3
| |
In regards to the Errno 50000: Sync token is no longer valid for [Contacts] table error, Rebuilding the xDB index in Solr should fix it but regrettably, it could not fix my issue.
Indeed, when rebuilding the xDB index, the rebuild collection will be updated, and you will need to swap the cores to ensure that the newly rebuilt core is active instead of the prior one. This is mentioned in the "Confirm rebuild" part of the documentation.
Therefore, I tried swapping the core mentioned in the Sitecore documentation but unfortunately, it's not working and returning me the error: "Not supported in SolrCloud".
I have gone through the SOLR guide documentation at https://solr.apache.org/guide/solr/latest/index.html and found that the SWAP command does not support a SolrCloud node.
Upon further exploration of the other API options, I found that the CREATEALIAS API might be suitable for addressing my requirement: CREATEALIAS: Create or Modify an Alias for a Collection
See the blog post for more details: Sitecore xDB Sync token is no longer valid for the [Contacts] Table
| xdb_collection.GetContactsChanges-Sync token is no longer valid for [Contacts] table
After rebuilding the xDB search index in SOLR Cloud, the data is not reflecting in the xdb_internal collection but is being updated in the xdb_rebuild_internal collection.
I have checked the Application Insight and found following exception:
*** [xdb_collection.GetContactsChanges], Line 27. Errno 50000: Sync token is no longer valid for [Contacts] table.
System.Data.SqlClient.SqlException at Sitecore.Framework.TransientFaultHandling.Sql.SqlRetryHelper+<>c__DisplayClass8_0`1+<<ExecuteAsync>b__0>d.MoveNext
I have gone through with the following articles and Q/A posted on StackExchange and applied the solution but its not solved yet:
https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-platform/rebuild-the-xdb-index-in-solr.html
Getting exception "Sync token is no longer valid for [Contacts] / [Interactions] table" with xConnect Search Indexer
https://akshaybarve.wordpress.com/2022/05/05/sitecore-xdb-rebuild-index-token-issue/
Sitecore XP Version: 10.3
SOLR Cloud SearchStax
Application has been deployed on Azure PaaS (Sitecore MCS)
| |
I don't know how the field item is retrieved in your PowerShell script, but I had this error when an item was read using Sitecore API and was not wrapped with automatic SPE properties using Initialize-Item:
The Initialize-Item command wraps Sitecore item with PowerShell property equivalents of fields for easy assignment of values to fields and automatic saving. This command can also be used to translate the the Sitecore.ContentSearch.SearchTypes.SearchResultItem items obtained from the Find-Item command into full Sitecore Items. The alias for the command is Wrap-Item.
See examples below.
This works:
$DefaultValueFieldName = "Default Value"
$myInputFieldItem = Get-Item -Path "master:/sitecore/Forms/Test form/Page/Firstname"
$myInputFieldItem.$DefaultValueFieldName = "some value"
This doesn't work and throws the error The property 'Default Value' cannot be found on this object. Verify that the property exists and can be set. because $myInputFieldRawItem does not have automatic properties:
$DefaultValueFieldName = "Default Value"
$myInputFieldRawItem = [Sitecore.Configuration.Factory]::GetDatabase("master").GetItem("/sitecore/Forms/Test form/Page/Firstname")
$myInputFieldRawItem.$DefaultValueFieldName = "some value"
But this works:
$DefaultValueFieldName = "Default Value"
$myInputFieldRawItem = [Sitecore.Configuration.Factory]::GetDatabase("master").GetItem("/sitecore/Forms/Test form/Page/Firstname")
$myInputFieldItem = $myInputFieldRawItem | Initialize-Item
$myInputFieldItem.$DefaultValueFieldName = "some value"
| Can't edit field directly in some cases using Sitecore PowerShell Extensions
I am trying to edit an item of template type /sitecore/templates/System/Forms/Fields/Input. This item has a field named Default Value.
Why does this work:
$DefaultValueFieldName = "Default Value"
$myInputFieldItem.Editing.BeginEdit()
$myInputFieldItem[$DefaultValueFieldName] = "some value"
But this doesn't update the field?
$myInputFieldItem.$DefaultValueFieldName = "some value"
In addition, I get this error:
ERROR: The property 'Default Value' cannot be found on this object. Verify that the property exists and can be set.
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
In fact, none of these other variations work either:
$myInputFieldItem."Default Value"= "some value"
$myInputFieldItem."Title"= "some value"
$myInputFieldItem."Css Class"= "some value"
Note that I CAN use this notation to edit other items successfully; just not in this case with this specific template type.
I am running the script as an administrator.
The software versions are:
Sitecore PowerShell Extensions 5.1.0.19766
Sitecore 9.0 Windows
PowerShell 5.1
| |
For those who are facing the same issue.
I have received a message from Sitecore Support with the statement:
This issue has been officially logged in the Content Hub product's system.
The bug report is identified by the reference number: MONE-40422.
They have not specified a timeline when it will be solved and released.
| Content Hub required field not showing message when placed in different column
We are using Sitecore Content Hub Cloud. And have set up multiple screens to create a new entity.
For the validation, we set up multiple fields that are required. To display this we have a creation page with multiple columns.
When saving the entity, for example Product, the validation works as expected. But not on all the required fields the error message is shown that it is mandatory.
What we want to see:
But when moving the field to a different column the red border and red error message is no longer shown.
Is there a setting I am missing to achieve this or is it something else?
The field we moved to a different column is Product families:
It shows the * that it is required but on save it is not being highlighted.
Thank you for your time and effort.
| |
Afaik Sitecore has Production and Nonproduction license. The production license is not expiring. Usually few months before is expiring you will receive from their sales representative calls or emails to inform you about license is expired.
Non production license or partner license will expired and you will receive a yellow screen when the license expired .
For the non production environment you can install a module which it shows a Content Editor Warning message or/and sends an email to notify when the Sitecore license is about to expire.
More information about License Expiration module you can find here: https://github.com/KayeeNL/Sitecore.License.Expiration.Module
| What happens when the Sitecore license got expired?
(In context of on-prem)
Imagine my SC license got expired, what happens next?
Will all my envs be unavailable or unusable? And is SC company able to postpone this (or vice-versa, block my envs just by pressing a button) remotely?
| |
I had the same issue on a 10.2 site a while back: ERROR SXA: Could not find 'id' attribute for node <r uid="{777E267C-D996-4D12-BF7D-7A24477B3BB8}" />
I used a script to detect all the pages that had this rendering uid:
$defaultLayout = Get-LayoutDevice "Default"
$useFinalLayout = $True
$pages = Get-ChildItem -Path "web:\sitecore\content" -recurse
foreach ( $item in $pages )
{
if (Get-Layout $item)
{
$renderings = Get-Rendering -Item $item -Device $defaultLayout -FinalLayout:$useFinalLayout
foreach ( $rendering in $renderings )
{
if ($rendering -ne $null -and $rendering.UniqueID.StartsWith("{777"))
{
Write-Host "$($item.ContentPath) - UID $($rendering.UniqueID) - ID $($rendering.ItemId) - template $($item.TemplateName)"
}
}
}
}
This gave a me a (long) list of items - I noticed that they were from 3 templates only, and for 1 template the id of the rendering was present. When I checked the standard values from that template I can indeed find a rendering with that uid. For the other template I cannot. Problem is also that I am new on the project and missing all history so I don't know what happened to the standard values of that template in the past.
For us this is also happening to a site that is not even a SXA site. It's an old setup where we added SXA (and a new site) recently.
We cleaned the items and that got rid of the errors. So it is "fixed", but I am still not sure why it happened.
| Error - "SXA: Could not find 'id' attribute for node"
I am seeing an error in my SC 10.2 (headless SXA) logs that I can't find any information about online.
When a call is made to this path:
/sitecore/api/layout/render/default?item=/some/page&sc_apikey={MY_KEY}&sc_site=MySite&sc_lang=en&tracking=true
I see an exception in the logs:
SXA: Could not find 'id' attribute for node <r uid="{B329D5C5-0077-44B2-9D64-A424C17B9B90}" ds="" />
This exception seems to be thrown by Sitecore.XA.Feature.Composites.Pipelines.GetXmlBasedLayoutDefinition.HandleCompositesPostback
These are all the traces around the time of the error:
I went to the offending item to inspect the raw values of the rendering fields.
Renderings:
<r xmlns:p="p" xmlns:s="s" p:p="1"><d id="{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}"><r uid="{6CAE9698-673B-43E3-8C33-A73DB1167CE1}" s:ds="" /><r uid="{B329D5C5-0077-44B2-9D64-A424C17B9B90}" s:ds="" /></d></r>
Final Renderings:
<r xmlns:p="p" xmlns:s="s" p:p="1"><d id="{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}"><r uid="{6CAE9698-673B-43E3-8C33-A73DB1167CE1}"><p:d /></r></d></r>
I can still preview and edit the page and I don't see any red flags in the presentation details viewer.
I am also seeing other instances of this error with other items that have a missing id on <r> nodes (with different uid values).
What's going on here?
| |
Sitecore applies config in the order defined in layers.config.
The default order is:
sitecore (i.e. App_Config/Sitecore)
modules (i.e. App_Config/Modules)
custom (i.e. App_Config/Includes)
environment (i.e. App_Config/Environment)
Based on the comments above, it sounds like you have tried manipulating the naming of your config file to be applied last (alphabetically) in the custom area.
If you have done this correctly and it has had no effect and layers.conig has not been customised. Then the only other possibility is that environment based configuration is overriding your attempts to patch the DefaultExternalUserBuilder.
Please check the App_Config/Environment folder to see if the Coveo file is present. If so and it need to remain, then you should be able to over ride by placing your file in the environment specific folder (ensuring its name begins later in alphabet - I.e. Z.yourfile.config).
Further information on configuration layers:
https://doc.sitecore.com/xp/en/developers/103/platform-administration-and-architecture/configuration-layers.html
| Unable to patch DefaultExternalUserBuilder in Sitecore 10.1.2
Our team is using Sitecore 10.1.2 with local environment hosted on developer machines, and deployed environments with K8s and Docker with Coveo serving all of those environments. Only in our deployed environments we are using federated authentication with Azure Active Directory but still using Sitecore's DefaultExternalUserBuilder. Attached is our showconfig.aspx, after I am attempting to patch the externalUserBuilder to use my assembly that I've created. As you can see, my patch is not showing up in the externalUserBuilder section and still shows that is using Sitecore's default. If I am reading this correctly, it appears that Coveo is being patched in using the default Sitecore user builder.
My patch config is also attached.
From what I understand is that the Coveo config is patched in by http request which may be configured to use the Sitecore default builder. If that is a correct assumption. Would anyone know how to get around that to use my CustomExternalUserBuilder?
| |
you can use following code to get all the roles assigned to the item.
item.Security.GetAccessRules()
| How to get assigned role for an item in C# code?
I assigned a role to a form. I need to get that extranet\Marketing from the form item. I tried to check the Security property and I was not able to get that. What is the right way to get the roles assigned to an item, in this case, a form?
| |
This question stems out of a misunderstanding between what is displayed on the cache.aspx page and what is shown as running total in the logs. Here's what Sitecore had to say about it:
Running total refers to the amount of cache sizes allocated for each cache so far. It is not the current size of the cache. It is more like a counter. The size of cache being allocated will be added to this counter when cache gets created. And would be reduced when cache is removed (less likely). This is why you may notice it growing every time it is logged. This helps us to understand the pressure on caches. You may see details of implementation in Sitecore.Caching.DefaultCacheManager::Register(ICacheInfo cache).
| Why doesn't the cache.aspx total cache size line up with "running total" size in logs?
When I check /sitecore/admin/cache.aspx I see a total cache size value of around 334000000 (334 MB). The size is consistent with what I see when doing a quick calculation of the current run size of all the entries.
However, when I check my Sitecore logs aorund the same time, they mention a "running total" which is much larger and doesn't seem to be correlated with what is shown on the cache.aspx page at all:
Cache created: 'RequestProtection.HashCache' (max size: 3MB, running total: 4595MB)
This is a headless 10.2 SXA CM instance running on an Azure App Service.
Why the delta?
EDIT
After continuing to monitor the logs, I noticed something even more perplexing. The running total size supposedly reached ~19 GB, which is impossible given that the App Service only has 16 GB of memory. Further, if that was actually true, I would expect to see the infrastructure at max memory load, and it is nowhere near that.
Meanwhile, the cache.aspx page shows a running total of only 522 MB .
| |
If you are using Sitecore Managed Cloud, then there is a known issue with the missing Optimization strip. Provided that you have enabled xDB.Enabled, xDB.Tracking.Enabled and ContentTesting.Enabled settings, you can just package those missing content items from another Sitecore instance and install it.
You can refer here for more details about the known issue.
| Optimization Tab didn't appears on Experience Editor
I'm experimenting with the issue where I have active all the content testing features, but on the Experience editor, I'm not seeing the optimization tab to control my tests
This is how I'm seeing:
And this is how I expected to see:
Does anyone know where I should grab the item to configure this correctly?
Regards,
Sergio Parissi
| |
The problem is you are using a Multilist with Search field, but supplying it with the source query used for a standard Multilist field.
On the Multilist with Search field, you are writing a query against the index vs using Sitecore Query.
Start with StartSearchLocation, in your case you would want something like StartSearchLocation=/sitecore/content/US/home, then you can add in a template filter, using the Guids of the templates vs the template names. So the source field would look something like:
StartSearchLocation=/sitecore/content/US/home&TemplateFilter={GUID}|{GUID2}
If you wanted to have your StartSearchLocation relative to the current item you are on, then you can use a query there too like this:
StartSearchLocation=query:./../home&TemplateFilter={GUID}|{GUID2}
References: https://thecodeattic.wordpress.com/2017/01/17/multilist-with-search-secret-sauce/
| Sitecore Template Source Query issue
So I have a multilist with search field that I ONLY want to add the items under my home folder per region. So I want my us site settings file to only pull in the US home items and then the CA Site settings to bring in CA only home items.
Currently my query is returning all of the items under CA, UK and US. Here is my query figure its something small but cant track it down.
query:../home//*[@@templatename='ContentPage_LeftNav' or @@templatename='ContentPage']
| |
this functionality doesn't exist without code customization in Sitecore XMC or Sitecore normal.
You can have such a functionality just if a specific user has rights to create/delete items just under a specific item X and other users doesn't create items under that X item.
| Delete permission for authors to delete items they have created themselves but no other items
In Sitecore XM Cloud, is there any way we can set delete permission for authors to delete items they have created themselves but no other items.
Preferably with no code customization.
Thanks
Shrutika
| |
You can follow this structure that includes your Main Navigation and sub-navigations. You can start with this and modify it as per your needs.
Main Navigation
- Shop (Template Name: First Level Navigation, Fields: Title)
- Mice (Template Name: Second Level Navigation, Fields: Title, Image, Link)
- Navigation Item (Template Name: Navigation Item, Fields: Title, Link)
- Navigation Item (Template Name: Navigation Item, Fields: Title, Link)
- Keyboard (Template Name: Second Level Navigation, Fields: Title, Image, Link)
- Navigation Item (Template Name: Navigation Item, Fields: Title, Link)
- Navigation Item (Template Name: Navigation Item, Fields: Title, Link)
- Webcam & Audio (Template Name: Second Level Navigation, Fields: Title, Image, Link)
- Navigation Item (Template Name: Navigation Item, Fields: Title, Link)
- Mobile Solution (Template Name: Second Level Navigation, Fields: Title, Image, Link)
- Navigation Item (Template Name: Navigation Item, Fields: Title, Link)
- Discover
- Item
- Navigation Item
- Item
- Navigation Item
- Item
- Navigation Item
- Business
- Item
- Navigation Item
- Item
- Navigation Item
- Support
- Item
- Navigation Item
- Item
- Navigation Item
- Item
- Navigation Item
Hope this helps.
| How to setup the data structure for top navigation
For menu like this one:
https://www.logitech.com/en-us
labels at the top
on hover, submenu opens
submenu can include subcategories labels as well as some images or custom components
each submenu may be different from others
I use React/NextJS to implement UI of the menu itself. Am totally new to Sitecore and was wandering what data structures should I use or how to structure dependencies in Sitecore to make it managable from CMS standpoint but also not use replacement column spots everywhere.
| |
The issue was due to us having unchecked "Automatically expose System Environment Variables":
We had done this previously due to adverse effects on next-auth-js. We were unable to override the PUBLIC_URL that it retrieved as it kept pulling the Vercel Domain and we rely on Cloudflare to proxy into Vercel with a .com (whereas Vercel provides a *.vercel.app domain OOTB).
This setting affects which instance of the Editing Data Service is used. With the ServerlessEditingDataService being required for Vercel. With process.env.VERCEL hidden, we were defaulting to BasicEditingDataService thus causing us the error.
https://github.com/Sitecore/jss/blob/dev/packages/sitecore-jss-nextjs/src/editing/editing-data-service.ts
So, if we check this box it breaks next-auth-js, but if we uncheck it, it breaks Experience Editor.
Our solution was to leave the checkbox unchecked and to instead manually add the variable VERCEL with a value of "1". This satisfies the condition in Sitecore-JSS and still allows next-auth-js to work properly.
It is worth noting that Sitecore JSS relies on a few other VERCEL system variables as well.
VERCEL_ENV: https://github.com/Sitecore/jss/blob/dev/packages/create-sitecore-jss/src/templates/nextjs-multisite/src/lib/middleware/plugins/multisite.ts
VERCEL_URL: https://github.com/Sitecore/jss/blob/dev/packages/sitecore-jss-nextjs/src/utils/utils.ts
| Error: Editing data cache miss for key; Unable to get editing data for preview {"key":"<GUID>"}
After upgrading from JSS 20 to JSS 21, we are unable to open pages in Experience Editor.
Our rendering host is Vercel and there are several errors in the logs:
Error 1:
T',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
joinDuplicateHeaders: undefined,
path: '/?timestamp=1708526618306',
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'clientname.vercel.app',
protocol: 'https:',
_redirectable: [Writable],
[Symbol(kCapture)]: false,
[Symbol(kBytesWritten)]: 0,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype],
[Symbol(errored)]: null,
[Symbol(kHighWaterMark)]: 16384,
[Symbol(kRejectNonStandardBodyWrites)]: false,
[Symbol(kUniqueHeaders)]: null
},
data: '<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>404: NotFound</title><meta name="next-head-count" content="3"/></html>'
},
isAxiosError: true,
toJSON: [Function: toJSON]
}
Hint: for non-standard server or Next.js route configurations, you may need to override the 'resolveServerUrl' or 'resolvePageUrl' available on the 'EditingRenderMiddleware' config.
Error 2:
Editing data cache miss for key 0893e6d7-8a9d-471f-ba1f-557b7d0990c2-jrtspdrkb1 at /tmp/if-you-need-to-delete-this-open-an-issue-sync-disk-cache/editing-data
Error: Unable to get editing data for preview {"key":"0893e6d7-8a9d-471f-ba1f-557b7d0990c2-jrtspdrkb1"}
at Object.exec (/var/task/.next/server/chunks/3853.js:643:10076)
at async /var/task/.next/server/chunks/3853.js:66:309586
at async /var/task/.next/server/chunks/3853.js:66:309576
at async /var/task/.next/server/chunks/3853.js:66:309576
at async /var/task/.next/server/chunks/3853.js:66:309576
at async /var/task/.next/server/chunks/3853.js:66:309576
at async Object.create (/var/task/.next/server/chunks/3853.js:66:309498)
at async getStaticProps (/var/task/.next/server/pages/[[...path]].js:1:2912) {
page: '/'
}
Error: Cannot find module '/var/task/.next/server/pages/500.js'
Require stack:
- /var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js
- /var/task/___next_launcher.cjs
- /opt/node-bridge/chunk-N3ULQXIM.js
- /opt/node-bridge/chunk-5UAC7W5H.js
- /opt/node-bridge/vercel-tla.js
- /var/task/___vc/__launcher/__launcher.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
at /var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:15:28048
at Module._load (node:internal/modules/cjs/loader:975:27)
at exports.b (/opt/node-bridge/chunk-5UAC7W5H.js:1:1033)
at /opt/node-bridge/bridge-server-BGIDXK2J.js:1:1443
at Function.Re (/opt/node-bridge/bridge-server-BGIDXK2J.js:1:1809)
at e.<computed>.L._load (/opt/node-bridge/bridge-server-BGIDXK2J.js:1:1413)
at Module.require (node:internal/modules/cjs/loader:1225:19)
at w.require (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:15:28264)
at require (node:internal/modules/helpers:177:18) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js',
'/var/task/___next_launcher.cjs',
'/opt/node-bridge/chunk-N3ULQXIM.js',
'/opt/node-bridge/chunk-5UAC7W5H.js',
'/opt/node-bridge/vercel-tla.js',
'/var/task/___vc/__launcher/__launcher.js'
]
}
Error: Unable to get editing data for preview {"key":"0893e6d7-8a9d-471f-ba1f-557b7d0990c2-jrtspdrkb1"}
at Object.exec (/var/task/.next/server/chunks/3853.js:643:10076)
at async /var/task/.next/server/chunks/3853.js:66:309586
at async /var/task/.next/server/chunks/3853.js:66:309576
at async /var/task/.next/server/chunks/3853.js:66:309576
at async /var/task/.next/server/chunks/3853.js:66:309576
at async /var/task/.next/server/chunks/3853.js:66:309576
at async Object.create (/var/task/.next/server/chunks/3853.js:66:309498)
at async getStaticProps (/var/task/.next/server/pages/[[...path]].js:1:2912) {
page: '/'
}
Error: Runtime exited without providing a reason
Runtime.ExitError
| |
On the file: sitecore\shell\Applications\Layouts\DeviceEditor\DeviceEditor.xml
you have
<Tab ID="ControlsTab" Header="Controls">
<div class="scStretch">
<Scrollbox ID="Renderings" Padding="0px" />
<div class="optionButtons">
<Button Header="Add" Click="device:add" style="margin-bottom: 6px"/>
<Button Header="Edit" ID="btnEdit" Click="device:edit" style="margin-bottom: 6px"/>
<Button ID="Personalize" Header="Personalize" Click="device:personalize" style="margin-bottom: 6px"/>
<Button Header="Change" ID="btnChange" Click="device:change" style="margin-bottom: 6px"/>
<Button Header="Remove" ID ="btnRemove" Click="device:remove" style="margin-bottom: 14px"/>
<Button ID="Test" Header="Test" Click="device:test" style="margin-bottom: 14px"/>
<Button Header="Move Up" ID ="MoveUp" Click="device:sortup" style="margin-bottom: 6px"/>
<Button Header="Move Down" ID="MoveDown" Click="device:sortdown" style="margin-bottom: 6px"/>
</div>
</div>
</Tab>
You need to decompile Sitecore.Shell.Applications.Layouts.DeviceEditor.DeviceEditorForm,Sitecore.Client and to hide the buttons based on current user and your needs.
| Disabling 'Remove,' 'Move Up,' and 'Move Down' Buttons of a Specific Rendering in Presentation Details and Experience Editor Based on User Role
How can we restrict the removal of a specific rendering from presentation details of any page item based on role? Everything else should function normally, such as editing the data source, etc.
My goal is to disable buttons such as 'remove,' 'move up,' and 'move down' in presentation details and restrict the removal or moving of a specific rendering from the Page item in both the content editor and experience editor."
Thank you.
| |
Broadly speaking, if you get this error, it's probably because there is a mismatch between your context item's path in the database vs. the context item's path stored in the index. A reindex should fix the issue, but chances are that there is a greater issue at play.
This question and solution is similar to what was explored here. The difference is that this solution is based on SXA whereas the other was not.
The problem is caused by a custom bucketing rule which updates the bucketed item's path based on a field value in conjunction with a save event handler that performs a BucketManager.Sync() operation, but does so within the context of an EventDisabler():
using (new EventDisabler())
{
BucketManager.Sync(bucketItem);
}
The deadly mistake here is the use of the EventDisabler which results in a mismatch between the item's path in the database vs. what is stored in the index (which has not been updated due to the EventDisabler).
Sitecore.XA.Foundation.LocalDatasources.Services.DataSourceLocationsService.GetRoots() is unable to resolve the context item and throws a null reference exception because it assumes that contextItem isn't null.
There are various solutions to this issue, the simplest being not to use EventDisabler when syncing buckets.
| Can't browse for rendering datasource and NullReferenceException in Sitecore.XA.Foundation.LocalDatasources
On my headless SXA 10.2 CM instance, I have a page in my tree (within a bucket) where if I try to browse for a rendering datasource, the popup does not appear, and an error appears in my logs. This happens for all renderings on the page, both in the shared layout and final layout.
When I click the "Browse" button, I see a POST request to /sitecore/shell/applications/field editor.aspx?mo=mini&hdl=xxxxx. This request gets a 302 response and an exception appears in the logs:
Exception: System.Web.HttpUnhandledException
Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Source: System.Web
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Nested Exception
Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj)
at Sitecore.Nexus.Pipelines.NexusPipelineApi.Resume(PipelineArgs args, Pipeline pipeline)
at Sitecore.Pipelines.Pipeline.Start(PipelineArgs args, Boolean atomic)
at Sitecore.Web.UI.Sheer.ClientPage.RunPipelines()
at Sitecore.Web.UI.Sheer.ClientPage.OnPreRender(EventArgs e)
at Sitecore.Shell.Applications.ContentManager.FieldEditorPage.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Nested Exception
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Sitecore.XA.Foundation.LocalDatasources
at Sitecore.XA.Foundation.LocalDatasources.Services.DataSourceLocationsService.GetRoots(Item contextItem, String query)
at Sitecore.XA.Foundation.LocalDatasources.Services.DataSourceLocationsService.GetDataSourceRoots(Item contextItem, Item renderingItem)
at Sitecore.XA.Foundation.LocalDatasources.Pipelines.GetRenderingDatasource.GetDatasourceLocation.Process(GetRenderingDatasourceArgs args)
at (Object , Object )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.XA.Foundation.LocalDatasources.CustomFields.FieldTypesEx.BucketInternalLink.ShowDialog(ClientPipelineArgs args)
I can only seem to reproduce the issue on one specific page item. If I duplicate that page item, I am able to browse for rendering data sources without issue. When I click the button, the POST to /sitecore/shell/applications/field editor.aspx?mo=mini&hdl=xxxxx gets a 200 response.
At first I thought this was an issue with a bad value in the renderings or final renderings, but both the problem item and the duplicated (working) item have the same exact values.
The source code for GetRoots() looks potentially problematic, but it's not clear what the exact issue is:
protected virtual Item[] GetRoots(Item contextItem, string query)
{
Item[] roots = (Item[]) null;
if (query.StartsWith("./", StringComparison.InvariantCulture) && !string.IsNullOrEmpty(contextItem.Paths.FullPath))
{
if (contextItem != null)
roots = contextItem.Axes.SelectItems(this.GetWorkingQuery(query));
}
else
roots = this.DatabaseRepository.GetContentDatabase().SelectItems(this.GetWorkingQuery(query));
return roots;
}
| |
The solution
These are generated automatically when certain fields are saved on the site definition item (/sitecore/content/<tenant>/<site>/Settings/Site Grouping/<site_definition>). You can regenerate it by changing and saving (and then changing back/saving again) either of the below fields:
Site name
Start item
For the curious
I discovered this by reviewing /sitecore/admin/showconfig.aspx and searching for "sitemap." I found the below handler under the item:saved event:
<handler type="Sitecore.XA.JSS.Foundation.SiteMetadata.EventHandlers.SitemapMediaHandler, Sitecore.XA.JSS.Foundation.SiteMetadata" method="OnItemSaved" patch:source="Sitecore.XA.JSS.Foundation.SiteMetadata.config"/>
Decompiling it, I found those two fields are inspected for changes and then a job is run to generate the media library item:
protected void OnItemSaved(object sender, EventArgs args)
{
Assert.ArgumentNotNull(sender, "sender");
Assert.ArgumentNotNull(args, "args");
if (!JobsHelper.IsPublishing() && Event.ExtractParameter(args, 0) is Item item && item.InheritsFrom(Sitecore.XA.JSS.Foundation.Multisite.Templates.JSSSiteDefinition.ID) && Event.ExtractParameter(args, 1) is ItemChanges itemChanges && (itemChanges.FieldChanges.Contains(Sitecore.XA.Foundation.Multisite.Templates._BaseSiteDefinition.Fields.SiteName) || itemChanges.FieldChanges.Contains(Sitecore.XA.Foundation.Multisite.Templates._BaseSiteDefinition.Fields.StartItem)))
{
string change = itemChanges.FieldChanges[Sitecore.XA.Foundation.Multisite.Templates._BaseSiteDefinition.Fields.SiteName]?.Value ?? item[Sitecore.XA.Foundation.Multisite.Templates._BaseSiteDefinition.Fields.SiteName];
SiteInfo siteInfo = SiteInfoResolver.Sites.FirstOrDefault((SiteInfo s) => s.Name.Equals(change.Trim(), StringComparison.OrdinalIgnoreCase));
if (siteInfo != null)
{
JobManager.Start(new DefaultJobOptions("SitemapMediaHandler", "SXA", "scheduler", this, "InitSitemapMediaJob", new object[1] { siteInfo })
{
CustomData = item.Database
});
}
}
}
| How do I regenerate the sitemap media item in a Headless SXA site without publishing?
I have an XM Cloud site I'm building locally and the current sitemap XML in the Media Library (/sitecore/media library/Project/<project_name>/<project_name>/Sitemaps/<app_name>/sitemap) is empty. How do I regenerate it with the pages I have added to my site for local testing?
A few things to note:
We're on Sitecore 10.3 and JSS 21 (Sitecore License Details says Sitecore XMCloud 1.5.62 (rev. 0)).
I cannot yet publish to Experience Edge, so if the generation requires publishing (as mentioned in this article), that won't work for me.
I have tried deleting the file, but it was not automatically regenerating.
When I hit the /sitemap.xml path on the CM, it generates and loads properly in the browser, but no media item is created.
When I try to hit /sitemap.xml on the rendering host, it shows an empty document (the file from the media library).
I have configured the <site>/Settings/Site Grouping/<site_name> item to have a target host name and host name and set the scheme to https.
| |
For language fallback you need to configure it for xmcloud instance and experience edge:
https://doc.sitecore.com/xmc/en/developers/xm-cloud/enable-and-set-up-language-fallback.html
https://doc.sitecore.com/xmc/en/developers/xm-cloud/enable-publishing-language-fallback.html
You have not shared, if you have applied any of those Sitecore configuration patches. From your description, it sounds you have not configured the publishing language fallback.
| Sitecore XM Cloud Language Fallback Works in Experience Editor but Not in Headless Application
I configured the Arabic language version at the site level and selected the English as the fallback language.
Then, enabled the item language fallbackand language fallback.
After that,created the data source for English only and selected the Arabic language version without a version number. It is displaying fallback content from English, as shown below.
Next, I configured this on one of my page items, and the language fallback content is rendering properly in the Experience Editor. However, it is not rendering the content in the headless application.
Could someone help me resolve this issue? Thanks.
| |
From what I know is that data cannot be shared between pages by default.
You could however create a custom form processinig feature
<processor type="YOURPROJECT.Feature.FormsProcessing.Pipelines.FormsPipeline.FormProcessorFieldValue, YOURPROJECT.Feature.FormsProcessing" patch:after="processor[@type='Sitecore.ExperienceForms.Mvc.Pipelines.GetModel.CreateModel, Sitecore.ExperienceForms.Mvc']" resolve="true">
On your second page you can add a hidden field with a token variable.
With the Form processor you can check the field if it matches you overwrite the token value with the submitted field value.
A small example for reference that could work:
public class FormProcessorFieldValue: MvcPipelineProcessor<GetModelEventArgs> {
public override void Process(GetModelEventArgs args)
{
// This token replacement is only valid on form fields that inherit from hiddenViewModel
if (!(args.ViewModel is HiddenViewModel hiddenViewModel)) return;
ReplaceTokensIfApplicable(hiddenViewModel, fieldId);
}
protected virtual void ReplaceTokensIfApplicable(HiddenViewModel hiddenViewModel, ID fieldId)
{
if (fieldId == new ID("{Field ID from submitted field}"))
{
// Get the value of the of previous page field
var textField = _formRenderingContext.GetPostedField(fieldId) as ListViewModel;
string selectedOption = textField == null ? string.Empty : textField.Value.FirstOrDefault();
if (!string.IsNullOrEmpty(selectedOption))
{
//Set token in hidden field with submitted value
if (hiddenViewModel.ItemId.ToLower() == "FIELD ID ON SECOND PAGE OF HIDDEN FIELD".ToLower())
{
hiddenViewModel.Value = selectedOption;
}
}
}
}
}
Then you should be able to use conditions on you page based on the hidden field.
Hope it helps you in some way.
| Sitecore Form 9.2. submit data trasfer
I have a Sitecore 9.2 form that is created with 2 Pages, The submit button on the first form redirects to the next page,
I need to display some text information on the second form based on some processing results on submission. I know it should be a custom action, but where this custom action should keep data for the second form page.
How to do it in a proper way ?
in other words, if first page has user name field how to display this value at secong page
is Session good solutions ?
| |
sc_link_info is not out of the box function.
It's a custom extension for Scriban which can be found on github: https://gist.github.com/auzick/c2e127ed4c6aef0f019eedc0ab738d2b
When you open page in Experience Editor, the else condition from 7th line of your code is not triggered, so the sc_link_info is not used. That's why you don't see exception in Experience Editor, only on CD server.
Here is more info how you can use the extension:
Accessing Link Field Values in a Scriban Template
| Using sc_link_info on Scriban template throwing error
I am new to Sitecore sxa, I have got SXA Scriban template being used in rendering variant. as
/Component-x/default/Link
and this Link has a field where following snippet is provided.
{{ if ( o_pagemode.is_experience_editor_editing ) }}
<div style="display: flex; flex-direction: column; padding: 10px;">
<div><b>Title:</b> {{ sc_field i_item 'Title'}}</div>
<div><b>CssClass:</b> {{ sc_field i_item 'CssClass'}}</div>
<div><b>Link:</b> {{ sc_field i_item 'Link'}}</div>
</div>
{{ else }}
{{ text = i_item.Title }}
{{ linkInfo = (sc_link_info i_item 'link') }}
{{ if linkInfo.text != "" }}
{{ text = linkInfo.text }}
{{ end }}
<a href="{{ linkInfo.url }}" alt="{{ text }}" title="{{ text }}" >
<svg>
<use xlink:href="/img/abcd/xyz.svg#{{ i_item.CssClass }}"></use>
</svg>
<span class="myClass">{{ text }}</span>
<i class="icon-indicator"></i>
</a>
{{ end }}
I am surely missing something here, and am thrown out with following error in just CD, while is ok in experience editor
/Component/d/Link(9,20) : error : The function sc_link_info was not found.
| |
Can you please verify your custom claims:
<IdentityResources>
<SitecoreIdentityResource>
<Name>sitecore.profile</Name>
<UserClaims>
<UserClaim1>name</UserClaim1>
<UserClaim2>email</UserClaim2>
<UserClaim3>role</UserClaim3>
<UserClaim4>http://www.sitecore.net/identity/claims/isAdmin</UserClaim4>
<UserClaim5>http://www.sitecore.net/identity/claims/originalIssuer</UserClaim5>
<UserClaim6>comment</UserClaim6>
<UserClaim7>fullName</UserClaim7>
</UserClaims>
<Required>true</Required>
</SitecoreIdentityResource>
</IdentityResources>
Also please verify the following configuration:
<ActiveDirectoryGroupTransformationAdmin type="Sitecore.Plugin.IdentityProviders.DefaultClaimsTransformation, Sitecore.Plugin.IdentityProviders">
<SourceClaims>
<Claim1 type="http://schemas.microsoft.com/ws/2008/06/identity/claims/group" value="Sitecore_Admin"/>
</SourceClaims>
<NewClaims>
<Claim1 type="http://www.sitecore.net/identity/claims/isAdmin" value="true"/>
<Claim2 type="comment"/>
</NewClaims>
</ActiveDirectoryGroupTransformationAdmin>
From your logs of the identity server info it seems like this:
You are missing some AllowedCorsOrigins settings in the Identity Server Allowed Cors Origins setting.
See the blog post for more details: Sitecore Identity Server in a nutshell
| Admin/Role is not mapped to Azure groups
I followed the this link to enable Azure AD as identity provider for my local Sitecore 10.1.3 instance. I can login with one of the user with admin groups mapped, but Sitecore gave me the following message:
it seems that the groups are not mapped to either admin or sitecore\author role. I developed a MVC app and verified that all groups of this user exist in the claim.
How do I troubleshoot this scenario? is there a way to know what claims send back to Sitecore identity server and how the map is done?
[Added new info]
In the log of identity server, there are some INFO not error like this:
2024-03-07T10:39:57.5610869-08:00 [INF] (Sitecore Identity/DEMO-SC101) Request starting HTTP/1.1 POST http://xp0identityserver.dev.local/signin-oidc application/x-www-form-urlencoded 2257
2024-03-07T10:39:57.5634166-08:00 [INF] (Sitecore Identity/DEMO-SC101) CORS policy execution failed.
2024-03-07T10:39:57.5635849-08:00 [INF] (Sitecore Identity/DEMO-SC101) Request origin "https://login.microsoftonline.com" does not have permission to access the resource.
2024-03-07T10:39:57.5637415-08:00 [INF] (Sitecore Identity/DEMO-SC101) No CORS policy found for the specified request.
[NEW] looks like login as user that was admin group, the admin flag will be set. but those users with content authors group, the role = "sitecore\author" is not set. even I manually add role "sitecore\author", after that user login, the role was removed.
<AzureGroupTransformation type="Sitecore.Plugin.IdentityProviders.DefaultClaimsTransformation, Sitecore.Plugin.IdentityProviders">
<SourceClaims>
<Claim1 type="groups" value="ba3a4750-1165-4082-bd3e-21d69d354f8c"/>
</SourceClaims>
<NewClaims>
<Claim1 type="role" value="sitecore\Author"/>
<Claim2 type="comment" />
</NewClaims>
</AzureGroupTransformation>
[Issue resolved]
After add CORS origins and added comment claim to role map, magically everything works now.
Thank you very much!
John
| |
From the mentioned link, Can you please replace the piece of code with the followings and verify:
var xdbCollectionCert = "StoreName=My;StoreLocation=LocalMachine;FindType=FindByThumbprint;FindValue=15E6693B0AECB63DE57D991EC363CA462DC52432";
var options = CertificateHttpClientHandlerModifierOptions.Parse(xdbCollectionCert);
var certificateModifier = new CertificateHttpClientHandlerModifier(options);
also instead of
var certificateModifier = new CertificateWebRequestHandlerModifier(options);
try with and verify. Hope it helps you.
var certificateModifier = new CertificateHttpClientHandlerModifier(options);
If you will check the Sitecore.Xdb.Common.Web namespace you will find that CertificateWebRequestHandlerModifier renamed with CertificateHttpClientHandlerModifier.
| xconnect namespace error on CertificateWebRequestHandlerModifier
Based on the information provided in the Sitecore documentation,
https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-platform/create,-retrieve,-and-search-contact-and-interaction-data.html
I am encountering an error related to a missing using directive or assembly reference when attempting to create a proof of concept (POC). Specifically, the error is related to the line of code:
var certificateModifier = new CertificateWebRequestHandlerModifier(options);
Can you please let me know the namespace that needs to be imported?
| |
Sometimes this issue comes because of firewall settings so if you check firewall settings then it should work.
Alternatively, you can manually add host entries and remove CreateHostHeader from the below JSON.
sitecore-XP0.json
xconnect-xp0.json
IdentityServer.json
More detail you can find here https://sitecorecorner.wordpress.com/2020/11/01/unable-to-update-hosts-file-while-installing-sitecore-10-using-sia/
| Sitecore 10.3 installation using Sitecore installation Assistant "unable to set lock on host file"
While attempting to install a new Sitecore instance for version 10.3,
I encountered the following error: Unable to get lock on file C:\WINDOWS\system32\drivers\etc\hosts after 10 attempt(s).
I have explored several resources suggesting adjustments to *.json files, but I am uncertain if this is the appropriate solution. Below is a screenshot of the error message for reference.
| |
Type field in Sitecore is a reserved field. This is used for field name resolution as mentioned below, which is a text field that cant contain multiple values.
https://doc.sitecore.com/xp/en/developers/90/platform-administration-and-architecture/using-solr-field-name-resolution.html
Field type in Solr is resolved by running below SOLR query which returns type_t.
https://{{solr_url}}/solr/{{solr_index}}/select?fq=_templatename:(Template field)&q=_name:({{field_name}})
This will return the type of that field as below:
You can find the default configuration for type field inside the fieldNames section as below which is of type text.
<fieldNames hint="raw:AddFieldByFieldName">
<field fieldName="type" returnType="text" />
</fieldNames>
Will suggest you to either the change the field name to some other name in order to resolve this issue.
| Sitecore Multilist not indexed as multivalue
I'm working on a Solr problem. We're in the process of upgrading a Sitecore 9.2 version instance up to a 10.3. It's a multi-tenant site in Sitecore. Hosting ~10 sites. All the sites share a solr index called sitecore_content_index.
The index populates, and indexes. But when looking at the logs I see errors complaining about a type not being a multi-value field. Which in turn skip the item in question...
solr.log:
2024-03-11 03:33:14.585 ERROR (qtp945722724-1802) [ x:sitecore_content_index] o.a.s.h.RequestHandlerBase org.apache.solr.common.SolrException: ERROR: [doc=sitecore://web/{fbbc927c-2b87-4752-9f68-62b6ae3b503e}?lang=en&ver=4&ndx=sitecore_content_index] multiple values encountered for non multiValued field type_t: [f91310793df347dca682682e7f4c8019, be83aedac1164131aa63244e5b9c606b] => org.apache.solr.common.SolrException: ERROR: [doc=sitecore://web/{fbbc927c-2b87-4752-9f68-62b6ae3b503e}?lang=en&ver=4&ndx=sitecore_content_index] multiple values encountered for non multiValued field type_t: [f91310793df347dca682682e7f4c8019, be83aedac1164131aa63244e5b9c606b]
at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:160)
org.apache.solr.common.SolrException: ERROR: [doc=sitecore://web/{fbbc927c-2b87-4752-9f68-62b6ae3b503e}?lang=en&ver=4&ndx=sitecore_content_index] multiple values encountered for non multiValued field type_t: [f91310793df347dca682682e7f4c8019, be83aedac1164131aa63244e5b9c606b]
at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:160) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.AddUpdateCommand.makeLuceneDocs(AddUpdateCommand.java:243) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.DirectUpdateHandler2.updateDocOrDocValues(DirectUpdateHandler2.java:962) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.DirectUpdateHandler2.doNormalUpdate(DirectUpdateHandler2.java:342) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.DirectUpdateHandler2.addDoc0(DirectUpdateHandler2.java:294) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:241) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.processor.RunUpdateProcessorFactory$RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:73) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:55) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.processor.DistributedUpdateProcessor.doLocalAdd(DistributedUpdateProcessor.java:263) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.processor.DistributedUpdateProcessor.doVersionAdd(DistributedUpdateProcessor.java:502) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.processor.DistributedUpdateProcessor.lambda$versionAdd$0(DistributedUpdateProcessor.java:343) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.VersionBucket.runWithLock(VersionBucket.java:50) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:343) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:229) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.update.processor.LogUpdateProcessorFactory$LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:106) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.handler.loader.XMLLoader.processUpdate(XMLLoader.java:263) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.handler.loader.XMLLoader.load(XMLLoader.java:190) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.handler.UpdateRequestHandler$1.load(UpdateRequestHandler.java:97) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(ContentStreamHandlerBase.java:82) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:216) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.core.SolrCore.execute(SolrCore.java:2637) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:791) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:564) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:427) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:357) ~[solr-core-8.11.2.jar:8.11.2 17dee71932c683e345508113523e764c3e4c80fa - mdrob - 2022-06-13 11:27:54]
at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:201) ~[jetty-servlet-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601) ~[jetty-servlet-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548) ~[jetty-servlet-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:600) ~[jetty-security-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1434) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501) ~[jetty-servlet-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1349) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:191) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.InetAccessHandler.handle(InetAccessHandler.java:177) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:322) ~[jetty-rewrite-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:763) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.Server.handle(Server.java:516) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:400) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:645) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:392) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277) ~[jetty-server-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) ~[jetty-io-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) ~[jetty-io-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:555) ~[jetty-io-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:410) ~[jetty-io-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:164) ~[jetty-io-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) ~[jetty-io-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) ~[jetty-io-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338) ~[jetty-util-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315) ~[jetty-util-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173) ~[jetty-util-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) ~[jetty-util-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409) ~[jetty-util-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) ~[jetty-util-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) ~[jetty-util-9.4.44.v20210927.jar:9.4.44.v20210927]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
The problem is, when I look at the Sitecore template of this item in question. The field is a multilist field, and in theory should be marked as a multi-value field in solr when indexing. I don't understand why this might be happening?!
So I've been looking at creating a custom computed field, that'll take this original Type, and return it back as a IEnumable<string> under a different field name called type_cp_sm.
This worked, and I do see the new field getting created and populated.
Then, I was looking at excluding the original type field to prevent the solr error. I've not yet worked out how I can do this exclude. But the idea was if I exclude the bad field, no error will be thrown, and the Sitecore Items that contain multiple types will be indexed as expected. (currently they're getting skipped due to the error...). So, in essence circumventing the problem... I'm taking this approach, because I don't know how I can override Sitecore's schema to force the type to be a multi-value solr field...
So my questions are:
Is this the best approach I'm taking? If so, how do I exclude the original field from the solr schema from sitecore's end?
Is there a way to prevent this error via another approach?
Why would the type field not be a multi-value field in solr if it's a multilist field in Sitecore?
I have looked at this documentation as well search and index configuration But I didn't quite understand where to put things.
/App_Config/Include/zzz/Custom_Index.config
Proof the type is a multilist. As seen here in the debug window.
Thanks in advance
| |
Creating a custom API will work for you. Where you can write this logic to create user into Sitecore database. Here is a code snippet that you can refer to.
System.Web.Security.Membership.CreateUser(domain\user, "password", "[email protected]");
For example
System.Web.Security.Membership.CreateUser(@"sitecore\myuser", "b", "[email protected]");
Hope this helps.
| Adding a CM User from External System to Sitecore
I am using Sitecore 10.1, there is a business requirements to allow external system to add CM users to Sitecore so my question is:
Is there an API that we can access to add the users in Sitecore?
| |
I was not able to determine the root cause of the issue. The only way I was able to get this working was by upgrading to a newer version of Sitecore CLI (5.2.113). I spoke with Sitecore support and that was their recommended solution as well.
Recommendation: update from Sitecore CLI version 4.x ASAP so that this does not become a blocker for you.
| Error connecting to ID host: An error occurred while sending the request
I am getting an error when running dotnet sitecore login:
PS C:\projects\MySite> dotnet sitecore login --cm "https://cm.mysite.localhost" --authority "https://id.mysite.localhost" --allow-write true -t
Looking for package [email protected]
Looking for package [email protected]
Finished resolving plugins. Total elapsed resolution time: 100ms
Logging in to environment default...
Logging in to Sitecore. You should see a browser window open shortly.
[InvalidConfigurationException] Error connecting to https://id.mysite.localhost/.well-known/openid-configuration: An error occurred while sending the request.
at Sitecore.DevEx.Configuration.Authentication.DeviceAuthorizationProvider.RequestAuthorizationAsync() in C:\BA\ca7111d945a16af4\src\Sitecore.DevEx.Configuration\Authentication\DeviceAuthorizationProvider.cs:line 110
at Sitecore.DevEx.Configuration.Authentication.DeviceAuthorizationProvider.Login() in C:\BA\ca7111d945a16af4\src\Sitecore.DevEx.Configuration\Authentication\DeviceAuthorizationProvider.cs:line 46
at Sitecore.DevEx.Configuration.Models.EnvironmentConfiguration.Login() in C:\BA\ca7111d945a16af4\src\Sitecore.DevEx.Configuration\Models\EnvironmentConfiguration.cs:line 176
at Sitecore.DevEx.Client.Tasks.LoginTask.LoginWithDeviceFlow(EnvironmentConfiguration environmentConfiguration) in C:\BA\ca7111d945a16af4\src\Sitecore.DevEx.Client\Tasks\LoginTask.cs:line 143
at Sitecore.DevEx.Client.Tasks.LoginTask.Execute(LoginTaskOptions options) in C:\BA\ca7111d945a16af4\src\Sitecore.DevEx.Client\Tasks\LoginTask.cs:line 63
at Sitecore.DevEx.Client.Cli.Subcommands.LoginCommand.Handle(LoginTask task, LoginArgs args) in C:\BA\ca7111d945a16af4\src\Sitecore.DevEx.Client.Cli\Subcommands\LoginCommand.cs:line 34
at Sitecore.Devex.Client.Cli.Extensibility.Subcommands.SubcommandBase`2.HandleInternal(TArgs args) in C:\BA\ca7111d945a16af4\src\Sitecore.Devex.Client.Cli.Extensibility\Subcommands\SubcommandBase.cs:line 75
All of this was working before and I am unable to determine what the specific issue is.
I am running the following:
Sitecore ManagementServices 4.0.0 rev. 00411.zip
dotnet 3.1.426
Sitecore SXA headless 10.2
All sites (CM, CD, ID) are hosted via Docker
Sitecore CLI 4.2.1 (4.2.1-r00505)
When I manually navigate to the supposedly failing endpoint https://id.mysite.localhost/.well-known/openid-configuration I can see that the certificate is valid, no redirects are occurring, and the response body looks valid:
{
"issuer": "https://id.mysite.localhost",
"jwks_uri": "https://id.mysite.localhost/.well-known/openid-configuration/jwks",
"authorization_endpoint": "https://id.mysite.localhost/connect/authorize",
"token_endpoint": "https://id.mysite.localhost/connect/token",
"userinfo_endpoint": "https://id.mysite.localhost/connect/userinfo",
"end_session_endpoint": "https://id.mysite.localhost/connect/endsession",
"check_session_iframe": "https://id.mysite.localhost/connect/checksession",
"revocation_endpoint": "https://id.mysite.localhost/connect/revocation",
"introspection_endpoint": "https://id.mysite.localhost/connect/introspect",
"device_authorization_endpoint": "https://id.mysite.localhost/connect/deviceauthorization",
"frontchannel_logout_supported": true,
"frontchannel_logout_session_supported": true,
"backchannel_logout_supported": true,
"backchannel_logout_session_supported": true,
"scopes_supported": [
"openid",
"profile",
"email",
"sitecore.profile",
"sitecore.profile.api",
"offline_access"
],
"claims_supported": [
"sub",
"name",
"family_name",
"given_name",
"middle_name",
"nickname",
"preferred_username",
"profile",
"picture",
"website",
"gender",
"birthdate",
"zoneinfo",
"locale",
"updated_at",
"email",
"email_verified",
"role",
"http://www.sitecore.net/identity/claims/isAdmin",
"http://www.sitecore.net/identity/claims/originalIssuer"
],
"grant_types_supported": [
"authorization_code",
"client_credentials",
"refresh_token",
"implicit",
"password",
"urn:ietf:params:oauth:grant-type:device_code"
],
"response_types_supported": [
"code",
"token",
"id_token",
"id_token token",
"code id_token",
"code token",
"code id_token token"
],
"response_modes_supported": [
"form_post",
"query",
"fragment"
],
"token_endpoint_auth_methods_supported": [
"client_secret_basic",
"client_secret_post",
"private_key_jwt"
],
"id_token_signing_alg_values_supported": [
"RS256"
],
"subject_types_supported": [
"public"
],
"code_challenge_methods_supported": [
"plain",
"S256"
],
"request_parameter_supported": true
}
On my ID container, the logs don't show any issues:
2024-03-12 09:38:55 [09:38:55] Microsoft.AspNetCore.Hosting.Diagnostics [Information] Request starting HTTP/1.1 GET http://id.mysite.localhost/.well-known/openid-configuration
2024-03-12 09:38:55 [09:38:55] IdentityServer4.Hosting.IdentityServerMiddleware [Information] Invoking IdentityServer endpoint: "IdentityServer4.Endpoints.DiscoveryEndpoint" for "/.well-known/openid-configuration"
2024-03-12 09:38:55 [09:38:55] Microsoft.AspNetCore.Hosting.Diagnostics [Information] Request finished in 1.3414ms 200 application/json; charset=UTF-8
I know that I have all of the prerequisites in place because I have ran:
dotnet tool restore
dotnet sitecore init
dotnet sitecore login --cm "https://cm.mysite.localhost/" --auth "https://id.mysite.localhost/" --allow-write true
My dotnettools.json is:
{
"version": 1,
"isRoot": true,
"tools": {
"sitecore.cli": {
"version": "4.2.1",
"commands": [
"sitecore"
]
}
}
}
I tried the following to re-auth:
Manually log out of and back into CM using admin credentials
Clear values from accessToken and refreshToken in user.json
Delete user.json file entirely
Clear browser cache and cookies on ID site
Flush DNS
Restart all containers
Clear browser history
Add "dns": ["8.8.8.8"] to Docker configuration
Tried it on another machine -- unable to reproduce the issue
Set insecure to true in user.json file
Cleared .sitecore files and reinitialized
One issue I have seen recently is that certain actions redirect me to the http CM site rather than https, to which the connection is refused. I can reliably reproduce this by logging out of CM, at which point a call is made to https://cm.mysite.localhost/identity/postexternallogout?nonce=b19bd38690314aeda5d305cb31e1317d&ReturnUrl=http%3a%2f%2fcm.mysite.localhost%2fidentity%2flogin%2fshell%2fSitecoreIdentityServer (notice the http instead of https).
The id Docker logs show this:
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Hosting.Diagnostics [Information] Request starting HTTP/1.1 GET http://id.mysite.localhost/connect/endsession?post_logout_redirect_uri=https%3A%2F%2Fcm.mysite.localhost%2Fidentity%2Fpostexternallogout%3Fnonce%3D547481361ffc4aa89de8a3d0f7eccc33%26ReturnUrl%3Dhttp%253a%252f%252fcm.mysite.localhost%252fidentity%252flogin%252fshell%252fSitecoreIdentityServer%253fsc_bw%253d1&id_token_hint=eyJhbGciOiJSUzI1NiIsImtpZCI6IjFDMzRBQkQ4MUQwMTM1Q0I1ODE3NDY2QzIzMTIzM0M2RUVEMzhGNTFSUzI1NiIsInR5cCI6IkpXVCIsIng1dCI6IkhEU3IyQjBCTmN0WUYwWnNJeEl6eHU3VGoxRSJ9.eyJuYmYiOjE3MTAyNjMzOTMsImV4cCI6MTcxMDI2NDg5MywiaXNzIjoiaHR0cHM6Ly9pZC5uaXhvbnBlYWJvZHkubG9jYWxob3N0IiwiYXVkIjoiU2l0ZWNvcmUiLCJub25jZSI6IjYzODQ1ODYwMTg4NDUzNzczNC5ZamN3WTJKaE5HUXRabUUyTlMwME1UTTFMV0ZsWVRJdE5tRTNPRGRrWVRVME9EWXpZVEkzTWpGaFl6SXRNMkUzTVMwME0ySXhMVGd6WVdFdFpXSmlOMk15WmpObE5XTm0iLCJpYXQiOjE3MTAyNjMzOTMsImF0X2hhc2giOiI0Y3JsanhjMUV0ZHlQVk1FMl93VzF3IiwiY19oYXNoIjoiQ2JVRFJUQy1uTDA3Rm9YaTVZTWx5ZyIsInNfaGFzaCI6ImlUMTNGYUs5WFk2eFRuYUo4cTZKaUEiLCJzaWQiOiJDRUMwNTUyQzVDNTNCQzVDNDc0QzUyMTYyRjg0MDQyNCIsInN1YiI6ImM0M2E1MTdlOTE4MjRmZTRiNGE2MGUxZjEzYzRmMTU1IiwiYXV0aF90aW1lIjoxNzEwMjYzMzkzLCJpZHAiOiJsb2NhbCIsImFtciI6WyJwd2QiXX0.IO7svYjVNt1URpOA7euBchCFhWpDxTOSJLVx3uAmGRS8TiGx7njWhNhezQnaw-9r7WWJMvlMX463EA0ipp-GTHR9BZ3w1r-Wbh7RO1mO2YFGE8q1rTqC1Pytt7_NIKKEehUfj_DJWpe1ApJl-7EH9LKCBuqcDlCWtBQIFExwjVYMl2w-Ficrc-dbzC5rEBWoppnZquQLs9KJddE7QHGme3CpzLeGE4L027A_wUUnckEMVvJqiv1Ly2GVUIjvQgA_pgdIGzo1U8tbajJoBLNXG-5ozaCRSbJvnPoVU4Dkf1t8J8BJ7hou1H-AnbvE68gTr5moxLUkZG0vhbSGx5qgUg&x-client-SKU=ID_NET461&x-client-ver=5.3.0.0
2024-03-12 11:19:06 [11:19:06] IdentityServer4.Hosting.IdentityServerMiddleware [Information] Invoking IdentityServer endpoint: "IdentityServer4.Endpoints.EndSessionEndpoint" for "/connect/endsession"
2024-03-12 11:19:06 [11:19:06] IdentityServer4.Validation.EndSessionRequestValidator [Information] End session request validation success
2024-03-12 11:19:06 EndSessionRequestValidationLog {ClientId="Sitecore", ClientName="Sitecore", SubjectId="c43a517e91824fe4b4a60e1f13c4f155", PostLogOutUri="https://cm.mysite.localhost/identity/postexternallogout?nonce=547481361ffc4aa89de8a3d0f7eccc33&ReturnUrl=http%3a%2f%2fcm.mysite.localhost%2fidentity%2flogin%2fshell%2fSitecoreIdentityServer%3fsc_bw%3d1", State=null, Raw={["post_logout_redirect_uri"]="https://cm.mysite.localhost/identity/postexternallogout?nonce=547481361ffc4aa89de8a3d0f7eccc33&ReturnUrl=http%3a%2f%2fcm.mysite.localhost%2fidentity%2flogin%2fshell%2fSitecoreIdentityServer%3fsc_bw%3d1", ["id_token_hint"]="***REDACTED***", ["x-client-SKU"]="ID_NET461", ["x-client-ver"]="5.3.0.0"}}
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Hosting.Diagnostics [Information] Request finished in 6.6267ms 302
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Hosting.Diagnostics [Information] Request starting HTTP/1.1 GET http://id.mysite.localhost/Account/Logout?logoutId=CfDJ8MlruGwz0zNPpoIZkNeZBloVlWDoECo3fkiHU01_F1gDvuBmAtucXSd6vcgRPPRIux65uXjEsJbq_S7WgO2TJyYDbPpBizg_xi0VjkoizaRxzhJ7LkjwR-QUnUiMIUU7IM1o3Zjxl1sH8L_UBYyE4wU0rPZ1Bmh1msupWIRRkJIn3SikkeuPGjpwZaZ9NoaDTwCA61Vx2sTsCRQelbiTCacxX3I7PeynJjCgc3tO16YAGRwmgvjoHnwliApG3KddZR2Ef72QWHrWVAxE0IyldAwPAbnUt8GieDxp0LFBS9IH3HyoMVsrQG4VD2fXtTobyxKa2ksw5VdMjBdFvPes3M5_c3s-UkZxQ3trUh9G8H8sPOUq44ok-Ye6sf6Vv-yEsUfR0UImiETQTxNw1j4Z9Ntr9tgo5EX-3cKT_lL7dI5aPnXovzqmIYPIpcfv59s5gjg-8rPe-KkjWUxsGxaCilSaVc_mp2_JGqy9mKc7CW0Yjbe_sGpuiIDMZLvvS8fXQmvwB7FyZucWor2NbjjRDuWq7CBSG53utDUMSoq3GEDMLDcNyxkPuJQNQtREjTtQWXWPiLv--hJIto6HNvT1p_R0eXpOMfY6GHGqClnTezEvbv_BsrMJX_04Obh7xbmHfpqvKVTvyZNZ3k02wa6dQNMwbqidJfpr3z3pMMZOPsGCGUGc3_JQv0FOH-X_EOW2WCayxBmvqZHA4p3mzF7mCtbw7UaHGqi395c-9I9OrGU9VY35l0I2EfoQvuG5QhxGXQN_gL09RZQYU2HblAmBBDktemxUkP6fNPhhsDonBy4F
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Routing.EndpointMiddleware [Information] Executing endpoint '"Sitecore.Plugin.IdentityServer.Controllers.AccountController.Logout (Sitecore.Plugin.IdentityServer)"'
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker [Information] Route matched with "{action = \"Logout\", controller = \"Account\"}". Executing controller action with signature "System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Logout(System.String)" on controller "Sitecore.Plugin.IdentityServer.Controllers.AccountController" ("Sitecore.Plugin.IdentityServer").
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler [Information] AuthenticationScheme: "idsrv" signed out.
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor [Information] Executing ViewResult, running view "LoggedOut".
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor [Information] Executed ViewResult - view "LoggedOut" executed in 5.1378ms.
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker [Information] Executed action "Sitecore.Plugin.IdentityServer.Controllers.AccountController.Logout (Sitecore.Plugin.IdentityServer)" in 13.2591ms
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Routing.EndpointMiddleware [Information] Executed endpoint '"Sitecore.Plugin.IdentityServer.Controllers.AccountController.Logout (Sitecore.Plugin.IdentityServer)"'
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Hosting.Diagnostics [Information] Request finished in 16.8808ms 200 text/html; charset=utf-8
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Hosting.Diagnostics [Information] Request starting HTTP/1.1 GET http://id.mysite.localhost/connect/endsession/callback?endSessionId=CfDJ.....
2024-03-12 11:19:06 [11:19:06] IdentityServer4.Hosting.IdentityServerMiddleware [Information] Invoking IdentityServer endpoint: "IdentityServer4.Endpoints.EndSessionCallbackEndpoint" for "/connect/endsession/callback"
2024-03-12 11:19:06 [11:19:06] IdentityServer4.Endpoints.EndSessionCallbackEndpoint [Information] Successful signout callback.
2024-03-12 11:19:06 [11:19:06] Microsoft.AspNetCore.Hosting.Diagnostics [Information] Request finished in 2.6068ms 200 text/html; charset=UTF-8
2024-03-12 11:19:36 [11:19:36] Microsoft.AspNetCore.Hosting.Diagnostics [Information] Request starting HTTP/1.1 GET http://localhost/healthz/live 0
2024-03-12 11:19:36 [11:19:36] Microsoft.AspNetCore.Hosting.Diagnostics [Information] Request finished in 0.372ms 200 text/plain
A potentially notable value in there is client-ver=5.3.0.0. If it's what I think it is, it's the wrong version.
Something similar happens when I log in -- I get redirected to http via this call after pressing log in: https://cm.mysite.localhost/identity/externallogincallback?ReturnUrl=&sc_site=shell&authenticationSource=Default, wherby the response sets the browser location to http://cm.mysite.localhost/sitecore/client/Applications/Launchpad?sc_lang=en.
Even if I just navigate to https://cm.mysite.localhost/sitecore, I get redirected to http://cm.mysite.localhost/sitecore/client/Applications/Launchpad?sc_lang=en. To actually get the page to load, I need to manually adjust http to https.
How can I troubleshoot further / fix this?
| |
When a user registers, you can create a new custom field in user profile. Below are the steps:
Select the Core database.
Open the Template Manager and select the User item. You can find it in the following path: templates/System/Security/User.
Edit the template, adding the fields you need. Sections can also be added.
SAVE the changes.
Select Master database and verify the new field is displayed on the User Manager/Edit User page.
As Igor said, in that custom field you can save value and for another user's login session you can check that value if it matches or not. If not then you can log out.
You can save custom values like the below code:
UserProfile customProfile = SitecoreUser.Profile;
using (new SecurityDisabler())
{
customProfile[fieldName] = stringValue;
}
customProfile.Save();
And get custom value like the below code:
var customField = currentUser.Profile.GetCustomProperty("custom");
| Log out an user from all it's different sessions on different browsers
We got a front-end website, where users can register and log in (and an extranet user is being created in Sitecore for that). We noticed, that on password change on one browser, the user stays logged in on all other browsers they were logged in. So the requirement is to log them out of all their sessions on password change.
I am trying to find a way to get all the sessions of the specific user and invalidate their logged in session. Is there a way in Sitecore to get all active sessions of an user? Or is there a totally different approach I could take to achieve my goal?
| |
Just use the constructore of ContactExecutionOptions which accepts ContactExpandOptions as a parameter like that:
new ContactExecutionOptions(new ContactExpandOptions(new string [] { PersonalInformation.DefaultFacetKey));
| How to transition from Obsolete ContactOptions to ExecutionOptions in xConnect xdbContext.GetAsync method
I am in the process of creating a Contact in xConnect and encountering the following warning message.
What are the modifications needed to convert code from utilizing the ContactExpansionOptions parameter to the ExecutionOptions parameter?
| |
For both of your questions, the best way to create a zip and download it, if you have multiple items in different folders.
Take this script as a reference.
#Upload Data Folder for CSV Upload
$dataFolder = [Sitecore.Configuration.Settings]::DataFolder
$tempFolder = $dataFolder + &quot;\temp\upload&quot;
$filePath = Receive-File -Path $tempFolder -overwrite
if($filePath -eq &quot;cancel&quot;){
exit
}
#Initiate the Items Array
$items = @()
$importList = Import-Csv $filePath
foreach ( $row in $importList ) {
$item = Get-Item -Path master: -Id $row.ID
if ($item){
$items += $item
}
}
#Now we got the list of items to be downloaded in an array.
#Pass on the array to the below out of the box script.
#Script copied from Script Library/SPE/Maintenance/Media Library Maintenance/Content Editor/Context Menu/Download
#Commented a line below to get items from CSV
function ZipItems( $zipArchive, $sourcedir )
{
Set-Location $sourcedir
[System.Reflection.Assembly]::Load(&quot;WindowsBase,Version=3.0.0.0, `
Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;) &gt; $null
$ZipPackage=[System.IO.Packaging.ZipPackage]::Open($zipArchive, `
[System.IO.FileMode]::OpenOrCreate, [System.IO.FileAccess]::ReadWrite)
#Commented this line as Items array is provided from the above script
#$items = @(Get-Item $sourceDir) + (Get-ChildItem -recurse $sourceDir)
[byte[]]$buff = new-object byte[] 40960
$i = 0;
ForEach ($item In $items) {
$i++
if([Sitecore.Resources.Media.MediaManager]::HasMediaContent($item)){
$mediaItem = New-Object &quot;Sitecore.Data.Items.MediaItem&quot; $item;
$mediaStream = $mediaItem.GetMediaStream();
$fileName = Resolve-Path -Path $item.ProviderPath -Relative
$fileName = &quot;$fileName.$($item.Extension)&quot;.Replace(&quot;\&quot;,&quot;/&quot;).Replace(&quot;./&quot;,&quot;/&quot;);
&quot;Added: $fileName&quot;
Write-Progress -Activity &quot;Zipping Files &quot; -CurrentOperation &quot;Adding $fileName&quot; -Status &quot;$i out of $($items.Length)&quot; -PercentComplete ($i *100 / $items.Length)
$partUri = New-Object System.Uri($fileName, [System.UriKind]::Relative)
$partUri = [System.IO.Packaging.PackUriHelper]::CreatePartUri($partUri);
$part=$ZipPackage.CreatePart($partUri, &quot;application/zip&quot;, [System.IO.Packaging.CompressionOption]::Maximum)
$stream=$part.GetStream();
do {
$count = $mediaStream.Read($buff, 0, $buff.Length)
$stream.Write($buff, 0, $count)
} while ($count -gt 0)
$stream.Close()
$mediaStream.Close()
}
}
$ZipPackage.Close()
}
$location = get-location
$time = Get-Date -format &quot;yyyy-MM-d_hhmmss&quot;
$zipName = Split-Path -leaf $location | % { $_ -replace &quot; &quot;, &quot;&quot;}
$zipPath = &quot;$($SitecoreDataFolder)\$zipName-$time.zip&quot;
ZipItems $zipPath $location
Download-File -FullName $zipPath &gt; $null
Remove-Item $zipPath
Close-Window
You can modify it a little bit as per your needs but it will fulfill your requirement.
For more reference:
https://www.nehemiahj.com/2022/05/
Hope this helps.
| Powershell script to download media library content to my machine
I have Sitecore 8.2 where I got spe version 6.4
I have got a csv file, where sample of data i.e. one row looks as
"Item ID","Title","Created","Changed","Media-ID","Related Site","Search Tags"
"{565E7592-8CA7-46D9-8399-2AB5E66C4EEB}","opening hours","4/17/2018 5:52:40 AM","4/23/2018 3:37:07 AM","{8BC6415F-DCB8-491B-BA3F-CD4FCF27CFD9}","Council", "About us"
Now, I want to download the media item used by this item whose item ID is in this sample data, {8BC6415F-DCB8-491B-BA3F-CD4FCF27CFD9} is a media item id used in this item, and the media is in /sitecore/media library path
so for this I have written script which is trying to read from csv file(where these above sample data are), then find 'Media-ID' column for each row and find the item in the given path based on the media item id
I am trying to download the media item using Send-File, and my script looks like
# Read the CSV file
$csvData = Import-Csv -Path "C:\Usman\news_export.csv"
# Loop through each row in the CSV data
foreach ($row in $csvData) {
$mediaId = $row.'Media-ID'
# Check if Media-ID is not empty
if (-not [string]::IsNullOrEmpty($mediaId)) {
$mediaItemPath = "master:/sitecore/media library"
Write-Host "Media ID: $mediaId"
Write-Host "Media Item Path: $mediaItemPath"
# Get the media item
$mediaItem = Get-Item -Path $mediaItemPath -ID $mediaId
# Check if media item exists
if ($mediaItem -ne $null) {
# Download the media item
Send-File -Item $mediaItem -Message "Download"
} else {
Write-Host "Media item with ID '$mediaId' not found."
}
}
}
My questions
How do I make this work/any other way to achieve this?
How do I specify a path to download, like if I need to download in C:\myImage\imageFolder ,how do I do that?
Thanks :)
Update:
Thanks Everyone, I am actually trying to read from
$csvData = Import-Csv -Path "C:\Usman\news_export.csv" and grab data from this csv from each row's "Media-ID" column. Then search on media library(based on media library path '\sitecore\media library') and search for that media item id. Which I have grabbed from csv already in above script.
The main thing is it does download but shows 0 kb with my code.
how do I create a zip package adding all these media items, and then download this zip specifying the path where is this zip to be downloaded
| |
function Convert-DateFormat {
param(
[string]$inputDateString
)
$inputDate = [datetime]::ParseExact($inputDateString, "yyyyMMddTHHmmssZ", $null)
$outputDateString = $inputDate.ToString("yyyy-MM-ddTHH:mm:sszzz")
return $outputDateString
}
You can use this method to convert your date to the new format.
You need to use also Sitecore powershell extension to update the fields
$item = Get-Item .
$item.Editing.BeginEdit()
$currentDateFieldName=$item.Fields["YourDateFieldName"].Value;
$item.Fields["YourDateFieldName"].Value =Convert-DateFormat($currentDateFieldName");
$item.Editing.EndEdit();
| Sitecore PowerShell script to convert Sitecore Date field data to other format
I am having Sitecore's Date field data coming as 20230804T000000Z, I also have time coming as 11 am. The Date is coming from Sitecore date field, and time from Single-Line Text field as below.
I need to combine these two and get the date and time as this format 2023-08-04T03:02:36+00:00
I got the date and time in my PowerShell using
$field_date_range_start_date = $item.Fields["Event Start Date"]
$field_date_range_start_time =$item.Fields["Event Start Time"]
have tried using
split() but out don't help out it says this is not supported
something like
$year = $dateString.Substring(0, 4)
$month = $dateString.Substring(4, 2)
$day = $dateString.Substring(6, 2)
and concat these to get yyyy-MM-dd format but didn't work out it says Substring() is not supported
ToString("yyyy-MM-dd") also didn't help work out it says this is not supported
[DateTime]::ParseExact( $field_date_range_start_date, "yyyy-MM-dd", [System.Globalization.CultureInfo]::InvariantCulture)
gives error in ParseExact
Is there anyway that I can achieve converting 20230804T000000Z to yyyy-MM-dd and combining with 11 am($field_date_range_start_time) and finally get my date variable to have format used in this sample 2023-08-04T03:02:36+00:00, using Sitecore PowerShell Script as I am exporting some of my data
Thanks
| |
This conversion from Dollar('$') to ('#') is occuring from the below code snippet inside Sitecore.DevEx.Serialization.Client.dll, which converts all the invalid file characters to '#' symbol.
I believe the changes were made to address and convert all the invalid characters to '#' using above code snippet.
Inside version 4.2.1 of Sitecore.DevEx.Serialization.Client dll, invalid file characters were replaced with underscore('_') symbol.
Below is the list of characters that are considered to be avoided in filenames.
https://www.mtu.edu/umc/services/websites/writing/characters-avoid/
Hope this helps!!!
| Why did SCS change branch template $name item paths to start with "_" instead of "#"?
I recently updated Sitecore CLI version 4.2.1 to 5.2.113.
I ran dotnet sitecore ser validate --fix and I noticed many of these log entries:
[/sitecore/templates/Branches/Project/ACME CO] INCORRECT FILE PATH: ~/Pages/General Content Page/$name,
[/sitecore/templates/Branches/Project/ACME CO] found: ~\ACME CO\Pages\General Content Page\_name.yml,
[/sitecore/templates/Branches/Project/ACME CO] expected: ~\ACME CO\Pages\General Content Page\#name.yml
[/sitecore/templates/Branches/Project/ACME] [M] ~\ACME CO\Pages\General Content Page\_name.yml -> ~\ACME CO\Pages\General Content Page\#name.yml
Notice how the branch template $name item's file path changed from _name.yml to #name.yml.
Why was this change made?
None of the release notes mention it:
5.1.25
5.2.109
5.2.113
| |
After upgrading I ran into build issues because of this.
After installing the necessary NuGet packages you're now missing because of the fact that they aren't dependencies anymore, you will get errors around having version numbers in your csproj files, so you will need to remove the version numbers. Then you'll need to add the package references to Packages.Props.
In my case, I was missing Microsoft.AspNet.Identity.Core, Microsoft.AspNet.Owin and Microsoft.Extensions.DependencyInjection.Abstracts. I just installed the NuGet packages and altered the csproj files and Packages.Props.
csproj:
Packages.props:
| Where have all my Nuget transitive dependencies gone?
Problem Statement
I'm upgrading a local environment from Sitecore 10.3 to 10.3.1. The platform is easy enough to upgrade using Docker with an update to my IMAGE TAG version: 10.3-ltsc2019 to 10.3.1-ltsc2019. Upgrading my Visual Studio solution should also be straightforward with Centralized Package Management using the Packages.props file.
Before
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PlatformVersion>10.3.0</PlatformVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Update="Sitecore.Owin.Authentication" Version="$(PlatformVersion)" />
<PackageReference Update="Sitecore.Kernel" Version="$(PlatformVersion)" />
<PackageReference Update="Sitecore.ContentSearch" Version="$(PlatformVersion)" />
<PackageReference Update="Sitecore.ContentSearch.Linq" Version="$(PlatformVersion)" />
<PackageReference Update="Sitecore.Assemblies.Platform" Version="$(PlatformVersion)" />
<PackageReference Update="Sitecore.Assemblies.SitecoreHeadlessServicesServer" Version="21.0.*" />
<PackageReference Update="Sitecore.LayoutService" Version="9.0.310" />
</ItemGroup>
</Project>
After
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PlatformVersion>10.3.1</PlatformVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Update="Sitecore.Owin.Authentication" Version="$(PlatformVersion)" />
<PackageReference Update="Sitecore.Kernel" Version="$(PlatformVersion)" />
<PackageReference Update="Sitecore.ContentSearch" Version="$(PlatformVersion)" />
<PackageReference Update="Sitecore.ContentSearch.Linq" Version="$(PlatformVersion)" />
<PackageReference Update="Sitecore.Assemblies.Platform" Version="$(PlatformVersion)" />
<PackageReference Update="Sitecore.Assemblies.SitecoreHeadlessServicesServer" Version="21.0.*" />
<PackageReference Update="Sitecore.LayoutService" Version="9.0.310" />
</ItemGroup>
</Project>
However, when I build my solution, I get several build errors for Nuget dependencies that were previously included in the 10.3.0 version.
Here's a comparison of the dependency tree for the Sitecore.Kernel nuget package:
Are developers expected to manually add any package dependencies for Sitecore 10.3.1 and above?
What up with that?
| |
This issue was fixed by disabling the firewall. The firewall was blocking the access. It can be blocked either by the default system firewall or any specialised software like cisco secure client.
| openid-configuration: DNS Fail
We are using Sitecore 10.3. For the local setup we are using docker. The local setup works fine(cm, id and frontend site) except logging in to Sitecore using Sitecore CLI. It is failing with below error.
Error connecting to https://id.abc.localhost/.well-known/openid-configuration: DNS Fail
I am using the below command to login into Sitecore via Sitecore cli.
dotnet sitecore login --authority https://id.abc.localhost
--cm https://cm.abc.localhost --allow-write true
It was working fine before, suddenly it stopped working without making any changes.
I have checked the host file and I can see an entry for id.abc.localhost and cm.abc.localhost.
When I browse the https://id.abc.localhost/.well-known/openid-configuration, I see a JSON result.
Also successfully flushed the DNS Resolver Cache using ipconfig/flushdns.
Still the issue is not resolved.
| |
You can refer to following code snippet to check if the agent is running.
DefaultJobStatus jobStatus = (DefaultJobStatus)JobManager.GetJob("{{agent_name}}")?.Status;
if (jobStatus != null && jobStatus.State != JobState.Running && jobStatus.State != JobState.Queued)
}
You can replace the agent name in the function with the name of your custom agent.
Hope this helps!
| How programmatically check if custom agent is running?
I have a custom agent that imports content from an external server. This process can take from 5 minutes to 2 hours. Agent can be started by scheduler or user. I want to prevent two same agents from running at the same time. Currently I have a flag in the DB that determines agent status. I set it to 1 when agent starts and to 0 just before agent stops. At the beginning of agent run I check flag and if it is 0 then agent starts.
It happens that there is an undefined event during import when agent stops and setting flag to 0 doesn't happen. As a result scheduler or user can't start next agent, because flag remains 1.
Is there a better way to monitor if agent is currently running? Any system variable or method?
Code:
public class ImportAgent
{
public void run()
{
if(agentRunning == 0)
{
//1. Setting agentRunning to 1
try
{
//2. Importing content
}
catch(Exception e)
{
//Error
}
finally
{
//3. Setting agentRunning to 0
}
}
else
{
//Agent is running. Waiting till next agent run
}
}
}
Config:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<scheduling>
<agent type="Name.Name.ImportAgent" method="Run" interval="00:30:00"></agent>
</scheduling>
</sitecore>
</configuration>
| |
No.
Commas , and periods . are stripped from the values. You can take a look at Sitecore.StringUtil.ParseSizeString(string) for proof, I've not found this officially documented anywhere.
Valid sizes examples:
12000 (bytes)
500KB (kilobytes)
25MB (megabytes)
2GB (gigabytes)
If you want 1.6MB, you're going to have to go with 1600KB.
More info: https://www.sitecorespark.com/blog/2018/8/why-sitecore-cache-sizes-are-listed-in-kb-mb-gb-in-configuration
| Are decimals supported when specifying cache size values?
Are decimals not supported when configuring cache sizes? I recently noticed that setting a cache size to 1.6MB resulted in the cache size being set to 16MB:
Patch Config
Below is the patch config where I set the cache size to 1.6MB:
showconfig.aspx Page
cache.aspx Page
| |
Yep.
DataSource=/Sitecore/Content/Home&IncludeTemplatesForSelection=section,page
Where section and page in this case, would be the templates you wanted to include.
More information here: https://doc.sitecore.com/xp/en/developers/92/sitecore-experience-manager/controlling-the-list-of-items-in-a-selection-field.html
| The Treelist's Sitecore query should show all items from a folder and restrict selection to a specific template
Is there Sitecore datasource query for a Treelist to display all items from a specific folder, while limiting selection to only items of a particular template?
| |
Can you check the modules section configured inside sitecore.json file is correct.
It should contain the path of the module file where the configuration for items to be synced are defined. You can specify module file by path or use wild card to include all the file names ending with module.json.
https://doc.sitecore.com/xp/en/developers/101/developer-tools/create-a-sitecore-content-serialization-module.html
Hope this helps!!!
| Getting message for Sitecore CLI-5.2.113 - dotnet sitecore ser pull
I am doing the Sitecore CLI setup on my local Sitecore site.
I am executing the following command - dotnet sitecore ser pull
but I am getting this below message instead of pulling Sitecore items as,
PS C:\Work\Sitecore\Repos> dotnet sitecore ser pull
[roles] Discovered 0 changes after evaluating role list.
[users] Discovered 0 changes after evaluating user list.
Anyone know how to resolve this?
| |
This can happen if the blob of the media item (the actual media data) no longer exists in the configured blob storage provider - in your case Azure Blob storage.
As a first step, check the credentials for the Azure Blob storage provider still work correctly as perhaps it is just a permission issue reading the blob.
Some other scenarios to consider that could lead to this issue:
Another Sitecore instance connected to the same storage endpoint and perhaps deleted that media item
Your instance or another instance ran the blob migration tool and didn't complete the process correctly
| DefaultMediaItemTextExtractor: Cannot extract content from media item with id - Expected pdf format
While reindexing my master / web indexes, the reindex failed and I saw these error messages in the logs:
Sitecore.ContentSearch.ContentExtraction.Common.DefaultMediaItemTextExtractor
Exception: System.IO.FileLoadException
Message: Expected pdf format
Source: Sitecore.ContentSearch.ContentExtraction
at Sitecore.ContentSearch.ContentExtraction.Readers.PdfSharpReader.ValidateIsPdf(String path)
at Sitecore.ContentSearch.ContentExtraction.Readers.PdfSharpReader.ReadAll(String filePath)
at Sitecore.ContentSearch.ContentExtraction.Common.DefaultMediaItemTextExtractor.ExtractTextFromMedia(MediaItem mediaItem)
On further inspection, the media library items in question did in fact have PDF files attached, but when I downloaded the attachment, its size was 0 bytes. However, the PDF must have had a size at some point, because the Size field has a value greater than 0.
How might this have happened? Worth noting is that the solution does make use of Azure blob storage to store media items.
| |
Based on the previous question, you are trying to redirect to 404 page inside the controller action. You can follow below steps to achieve the same.
Step1: Create the custom class extending ActionResult as below.
public class TransferResult : ActionResult
{
public string Url { get; set; }
public TransferResult(string url)
{
this.Url = url;
}
public override void ExecuteResult(ControllerContext context)
{
if (context == null)
throw new ArgumentNullException("context");
context.HttpContext.Server.TransferRequest(this.Url, false);
}
}
Step2: Inside the controller Action method you can return the custom ActionResult Type created above, depending on the condition when the video does not exist on the vimeo service.
public ActionResult Video()
{
var videoExist = false; //code to check if video exist
if(!videoExist){
return new TransferResult("{{url_for_404_page}}");
}
return View("");
}
This will transfter the request to 404 page without the url being changed, inside the controller action.
Hope this helps!!!
| Trouble getting GetPageItemProcessor implemented
I asked a question "how to trigger 404 in controller", my post was closed and pointed me to an early question which was considered answered. I followed that link and tried to implement PageItem404: GetPageItemProcessor as described in the answer, I got compile error says
CS7036 There is no argument given that corresponds to the required formal parameter 'baseClient' of 'GetPageItemProcessor.GetPageItemProcessor(BaseClient)'
After I added the constructor like following
public PageItem404(BaseClient baseClient) : base(baseClient) { }
the pipeline throw exception after I added patch to configuration:
Server Error in '/' Application.
Could not create instance of type: Common.Feature.Errors.Pipelines.HttpRequest.PageItem404. No matching constructor was found. Constructor parameters:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Sitecore.Exceptions.ConfigurationException: Could not create instance of type: Common.Feature.Errors.Pipelines.HttpRequest.PageItem404. No matching constructor was found. Constructor parameters:
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
how to correctly implement GetPageItemProcessor and get it to work?
| |
Yes. You can unzip the package. Inside that there will be package.zip. Unzip package.zip and inside that you will find installer folder, inside Installer folder open project file.
This project file is an xml file where you can see all the sources of package.
You can also see all the items in items folder. In this folder all the items from selected source are serialized. And can see all the files from files folder (if there are any files)
| How to find out what is in a Sitecore Package without installing it
Once I have created a package and downloaded it to my system from Sitecore, is there any way to know what the package contains, maybe just path of those items.
I want to achieve this with out downloading the package into other environment.
| |
This issue is because of mismatch of language codes.
In solr document, both languages exist (like de-de and de-DE) but still there is no result when we use the filter "de-de".
We need to pass the language code like de-DE if we pass the language code like de-de the dictionary values will not be retrieved.
This has been identified as a Sitecore bug with a reference number 610566 by the sitecore support team.
| Not getting dictionary items/values for non en languages from web db
We are using Sitecore Headless. We are not getting dictionary values for non en languages from web db which is used for preview site.
We tried to get the dictionary values using Graph QL Query. We were able to get the values for en but we were not able to see the dictionary values for non en language sites.
Graph QL Query
-------------------------------------------
query DictionarySearch(
$rootItemId: String!
$language: String!
$templates: String!
$pageSize: Int = 100
$after: String
) {
search(
where: {
AND: [
{ name: "_path", value: $rootItemId, operator: CONTAINS }
{ name: "_language", value: $language }
{ name: "_templates", value: $templates, operator: CONTAINS }
]
}
first: $pageSize
after: $after
) {
total
pageInfo {
endCursor
hasNext
}
results {
key: field(name: "Key") {
value
}
phrase: field(name: "Phrase") {
value
}
}
}
}
|