We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [sitecore-api]

For questions related to Sitecore's API, covering questions about how to access, create, update or or delete data, as well as questions about how the Sitecore code-base is or can be used for custom or native logic, etc.

Filter by
Sorted by
Tagged with
17
votes
3answers
2k views

What does headless mean in the context of Sitecore?

There have been numerous discussions around headless capabilities supported by the Sitecore platform. What does that even mean? What product offerings from Sitecore support headless capabilities? ...
11
votes
1answer
257 views

How can I write my own custom disabler?

Sitecore ships with a bunch of disablers, like the SecurityDisabler and the EventsDisabler, but what if I want to write my own? I have a bunch of item:saved event handlers that run but when I add a ...
10
votes
3answers
390 views

When to use Sitecore.Context.Items and why?

I just found Sitecore.Context.Items object as part of the Sitecore.Context. What is the use-case of using it and when I shouldn't use it?
9
votes
3answers
4k views

What is the best way to bulk-create items programmatically? [closed]

What is the best way to create many items in bulk under a certain item, using code? What are the things to consider in such scenarios? What are the pros and cons?
9
votes
2answers
5k views

How to get the our local date and time from the sitecore datetime field(raw value format - yyymmddThhmmssZ)?

I have set the date in the sitecore item for some datetime field as below. And its getting saved as below format in the master/web database. 20170401T073000Z When I try to get that value using the ...
9
votes
1answer
135 views

Field StandardValue vs DefaultValue vs FallbackValue vs InheritValue vs InnerValue

The parameters of the GetValue methods of the Sitecore.Data.Fields.Field class enable developers to restrict the origin of the returned value to the Fields: StandardValue DefaultValue FallbackValue ...
8
votes
2answers
202 views

What is alternative of “.PageMode.IsExperienceEditor” property in JSS-react?

What is alternative of .PageMode.IsExperienceEditor property of Sitecore.Context in JSS-react to verify the ExperienceEditor context ?
8
votes
1answer
242 views

Item statistic “CreatedBy” returning empty string

Im trying to get the creator of an item, but when I access the CreatedBy property, it returns an empty string. When I debugged I could see the all the other fields were populated, but not the ...
8
votes
2answers
430 views

Login to Sitecore 9.1 across multiple subdomains

I am trying to login to Sitecore across multiple domains. I mean, I have two different sites abc.x.com and xyz.x.com. is there a way to set the auth cookies at parent domain level, in my case at x....
7
votes
1answer
120 views

Is there a method in Sitecore's utilities to format a numerical file size in a friendly way?

The title pretty much says it all. I feel like I've come across a method in the past that does something like: long fileSize = 524288000; string prettyFileSize = Sitecore.SomeUtility....
7
votes
2answers
444 views

How to copy an item to multiple locations

What is the easiest and quickest way to copy an item to various locations? I have about 100 multisites in a solution and I have created a new template. I need to create a new item inheriting this ...
6
votes
1answer
1k views

TemplateManager.GetTemplates always returning null

Got the following call: var templatePath = "/User Defined/Project/Common/Content Types/Links"; var template = TemplateManager.GetTemplate(templatePath, Context.Database); This is always returning ...
6
votes
2answers
1k views

Get Items by template id in a scheduled task

Scenario: I have over 10,000 items in my sitecore/content tree. Nearly 2,000 of them are thrived from the Article template. Inside of the Article items, there are two important fields: Is Featured - ...
6
votes
3answers
189 views

Exposing ServiceApiController in Sitecore 9.2

I am trying to expose a MVC route in Sitecore 9.2 for a web api I am creating. I followed the steps describe here but it only works when my controller inherits from controller. If I inherit it to ...
6
votes
1answer
1k views

How to get Descendants of a Sitecore item using Glass mapper?

Is there any direct approach to get descendants(child items and sub child items) of a Sitecore item in Glassmapper model. I know [SitecoreChildren] can be used in GlassMapper model to get Child items....
5
votes
2answers
629 views

Headless CMS : Sitecore vs Contentful

We are currently using Sitecore for one project but did not use JSS anywhere. Other project team plans to use headless CMS and considering "Contentful" CMS for this. Could anyone please explain the ...
5
votes
1answer
238 views

What is the ShutdownGuard and how should I use it?

I heard someone mention the use of ShutdownGuard for long running precesses. How does one properly make use of this and what are some cautions around its usage?
5
votes
1answer
651 views

How to invoke Workflow on the particular item using Sitecore API?

We have the list of items in the Sitecore tree and all the items will be in a workflow. we are updating these items programmatically and based on some condition, we have to assign the state of the ...
5
votes
1answer
122 views

Creating friendly imageurl in scheduled job

I am using a scheduled job to import some content into Sitecore. Hereby I am inserting inline images into a rich text editor field. I determine the src of the img tags by using: string url = ...
5
votes
2answers
393 views

How does one access a Security field programmatically?

Back in Sitecore 5 there used to be a class, Sitecore.SecurityModel.SecurityField. Seems like this class was removed in later versions. So, how does one access a Security field on an item now? ...
5
votes
1answer
96 views

How to update XDB with customer details in a separate thread

I noticed the call to update the customer details onto xDB is taking considerable amount of time so I would like to do it in a separate thread so that application does not have to wait until the ...
5
votes
1answer
808 views

Get List of Contacts in a ListManager and associate one more contact to it

I have a requirement to get Contact data from a Registration page and save that data into a List Manager in Sitecore. I followed the below approach. //Create ListManager Object var listManager = (...
5
votes
1answer
897 views

Getting a list of items from the ItemService API matching a specific field value

I'm trying to get a list of items from Sitecore that match a custom tag field. This is from an external application so I need to use one of the APIs to do this. I've tried using the Sitecore ...
4
votes
2answers
2k views

How do I get an Item from Sitecore's internal URI protocol?

I have a reference to an item that uses the sitecore: protocol: "sitecore://master/{...GUID HERE...}?lang=en&ver=0" I could attempt to parse this URI manually to look up the item, but I'm pretty ...
4
votes
3answers
1k views

Sitecore Item - Generated HTML

One of client wants to send email using standard .NET SMTP client. I would like to know How I can generate HTML of my Sitecore item which has all layouts and renderings configured and assigned that ...
4
votes
1answer
383 views

Change field type from Droplist to Droplink

I have content items with Droplist field. I want to change this field to Droplink field type. What is the best solution/practice to change it without losing already existing data?
4
votes
2answers
75 views

Is Virtual user concept available in XM version?

One of the client is having an XM license and they need to implement the virtual user concept of the Sitecore do they need to update the existing licence or this feature is already supported with the ...
4
votes
1answer
66 views

Is the 100 child item limit still a valid rule of thumb?

I always understood that Sitecore recommends having fewer than 100 items under a node. Is this rule still valid? Does having too many child items only impact the Content Editor when opening the ...
4
votes
1answer
208 views

Sitecore's Publishing setting vs. a Custom field

I'm using Sitecore 8.2 - update 2. Scenario: I like to list all of the articles sorted by a Publish Date. Which is the best practice/approach? Sitecore's Publishing Setting: Use Sitecore's OOTB ...
4
votes
1answer
470 views

Sitecore 9 in Azure PaaS : Add Application Insights SDK

For Sitecore 9 on Azure PaaS and newer versions, what is the best practice to Add and configure the Application Insights SDK in Visual Studio to generate some telemetry in Visual Studio. As we are ...
4
votes
1answer
668 views

Receiving 404 error when accessing Item Web Api with Sitecore 7.2

Im trying to use the item web api in sitecore 7.2 to retrieve https://[hostname]/-/item/v1/sitecore/content/ in postman, but it returns a 404 not found error (the whole 404 not found html page of ...
4
votes
1answer
80 views

“Error occurred” (500) when collecting basic information about your Sitecore installation

I have raised a ticket on the Sitecore support portal. They asked me to provide basic information about my Sitecore site from each instance in your environment. Check the article https://kb.sitecore....
4
votes
1answer
156 views

Livetime section Valid From and Valid To

I have item with publishing restrictions. After apply restriction for item I see that in Livetime section Valid From and Valid To fields was set. It's ok. But when I'm trying to get item by id: ...
4
votes
1answer
68 views

JSS layout api returns 404 when item requested by display name

We are trying to use display names for URLs and it doesn't work with JSS. E.g. we have a page "search" which has a display name in NL: zoeken. when I request http://localhost:3000/en/search , the JSS ...
4
votes
1answer
47 views

GraphQL Search facetOn Parameter

I'm trying to use the Sitecore GraphQL search function that takes in the "facetOn" parameter. Unfortunately I'm not having much luck with the results, and I suspect it's because I'm doing something ...
4
votes
1answer
86 views

Content Item batch retrieval in .Net code?

Is there a way to retrieve a set of content items from Sitecore's APIs in batches, besides using the REST API? I'm looking at improving performance for a client's Sitecore site. A lot of the legacy ...
4
votes
1answer
81 views

Logic for Enroll contacts from list in Sitecore 9.1

There is a new cool feature called Enroll contacts from list in Sitecore 9.1: I'm wondering where the actual logic resists (which assembly and class). I'm going to utilize this functionality by ...
4
votes
0answers
236 views

Unable to get Dictionary Item value using sitecore Scheduler event

I have created A Sitecore Scheduled Task to send email. I have to read some settings from a Sitecore Dictionary but receiving only key not value. After debugging I have found that Sitecore.Context is ...
4
votes
1answer
566 views

Getting the page ID when clicking a custom link field in Sitecore

I am creating a new link field in Sitecore following this link: Link for custom link field I have successfully created one called modal link. Specifically I want to get all the modal components that ...
3
votes
1answer
187 views

Accessing SXA Site Grouping Site Settings Properties from Code

I have a SXA site created and under "/settings/Site Grouping" I have defined a Site item. I want to access "Other Properties" fields (ex: "dictionaryPath" which I have added into Other properties) ...
3
votes
1answer
318 views

What’s the best practice to Expose Sitecore 9 APIs for Mobile Apps Development? [closed]

Currently, I am looking Sitecore CMS solution for native mobile app development. Mobile App Team is using Swift for IOS and Java for Android. So we have a limitation to use JSS react native for ...
3
votes
5answers
848 views

Cannot find packages containing StandardController

I am very new to Sitecore, trying to implement a basic controller inheriting from StandardController. I've followed the official Sitecore docs for setting up the environment to work with MVC here: ...
3
votes
2answers
2k views

Create an item with a specific ID and Branch

I found an article showing how to create an item using a branch. https://briancaos.wordpress.com/2009/12/01/creating-items-from-branches-in-sitecore/ I found another article showing how to create an ...
3
votes
2answers
570 views

“Silently” Create Item - Create Item Without Triggering Indexing or other Events

I know that when I edit items, I can pass true to the EndEdit method to save the item without triggering events/indexing on save. Since I almost always want to edit an item after creating it, it seems ...
3
votes
1answer
113 views

Create media item and specify item id

I have a scenario where I need site visitors to be able to upload media items via CD server. My plan is to upload to web database first and use EventQueues to then have the CM server fetch the ...
3
votes
1answer
486 views

LinkManager.Provider is deprecated in Sitecore 9, how to get the default provider then?

The following code works in Sitecore 8.2 but not in Sitecore 9: var provider = LinkManager.Provider; The Provider property is not available anymore in Sitecore 9 Sitecore.Kernel, what should I use ...
3
votes
1answer
311 views

Change WFFM file upload button text

I created a WFFM form with File upload field to upload the files and using it in russian website. But the file upload button text and placeholder are displaying in English and I did not find any ...
3
votes
1answer
47 views

How do I show custom error message on OnItemSaved event?

The ask is to show the following kind of message on the OnItemSaved event. I am unable to show a similar custom message on the OnItemSaved event. I am always getting some default exception ...
3
votes
2answers
307 views

Sitecore Tagging

We have requirement where if a Content Item is Tagged with “Espresso” and “Cappuccino” then this content Item will automatically be populated in the page when searched for both types of tags “...
3
votes
0answers
25 views

Restoring marketing taxonomies with Sitecore powershell extenstion

I am trying to automate Sitecore upgrade from 8.1 to 9.0.1. In Upgrade steps, There is one step restoring deleted marketing taxonomies, which can easily be done with Url navigation and click button on ...