Posts

Contact Profile Image Using Avatar Facet in Sitecore

Image
Sitecore xConnect provides several default facets like personal information, AddressList, EmailAddressList, etc. Avatar is one of them and it comes under the IContactPicture Legacy facet. If you are new with Sitecore xDB and xConnect and need more insight on the Custom facet, How to create and set/update the facet then you can refer blog post Work with Custom Facet in Sitecore and Create Custom Facet in Sitecore. In this article, I am going to describe how to set the contact picture in the Avatar facet which we can see in the details tab in the experience profile window. private bool SetAvatarFacets(byte[] imageBytes, string mimeType, Contact contact, IXdbContext client) { var pictureData = imageBytes; var pictureMimeType = mimeType; var avatar = contact.GetFacet<Avatar>(Avatar.DefaultFacetKey); //Facet is null if (avatar == null) { avatar = new Avatar(pictureMimeType, pictureData);

Uninstall Sitecore Instance Manually

Image
In this blog, I will let you know how to completely remove the Sitecore instance from your machine manually. While installing the new instance we face the error regarding SQL Server, Sitecore Identity Server, etc. To overcome this situation, perform the below steps to entirely clean the old Sitecore instance and you can go with a smooth installation of the new instance. Stop the IIS and remove the configuration: Open the IIS server and in the right panel Action tab click on Stop. Again, in the left panel right-click on the Sitecore instance and choose the Remove option. In the left panel go to the application pool, select all respective Sitecore Instance application Pool and choose the remove option from the right panel. For example, in this blog, I am deleting the "sc1011sc.dev.local" instance. Delete Sitecore Service: Go to the Service window, Press the Win + R key, it will open the run windo

Lazy Loading in Glass Mapper

Image
Lazy loading is on-demand loading, when users request the content by Lazy loading then instead of loading the whole content on your page it loads only required content, till further request by users. Disable Lazy Loading in Glass Mapper: Individual Get-Item Method All Sitecore Service Methods Individual Get-Item Method: In Sitecore Service Method: var item = _service.GetItem<ICustomModel>("/sitecore/content/Home/Course", x=>x.LazyDisabled()); In MVC Context method: var item = _mvcContext.GetDataSourceItem<ICustomModel>(new GetKnownOptions { Lazy = Glass.Mapper.LazyLoading.Disabled}); All Sitecore Service Methods:  If you don't want to pass x.LazyDisabled() in all the GetItem methods then prefer the Generic Class approach. Create a Generic Class as below: public class RenderingRepository : IRenderingRepository { private readonly IMvcContext _mvcContext; public RenderingRepository(IMvcContext mvcContext)

Sitecore Technology MVP Journey 2022

Image
"Rome was not built in a day" , prominent idioms and one of my favorite quotes enthuse me a lot in life. It says, to achieve a long-term goal properly takes a long time and you should not hurry through for it. To get the badge of Sitecore MVP particularly in Technology for me is one of them. My journey for Sitecore MVP begins in the Year 2019. I commenced with Sitecore Technology blogs , actively participate on the Sitecore Stack Exchange Platform and Sitecore Slack Channel . I am honored to be named Sitecore Technology MVP 2022 . I feel fortunate to be participating with a Sitecore Community, Technology, and Product. I am happy that my all efforts and contributions are recognized by Sitecore and Community. My next focus for this year would be: Exploring more in Sitecore Project including Sitecore Content Hub, Docker, Headless, and Jam stack architecture Continuing with sharing and helping others into Sitecore Community.

Checkbox Rendering Parameter Taking Null Value If It's Unchecked

Image
Issue: I have a client requirement that each component should be flag-based to turn it on or off. I have used a checkbox in rendering parameters for the implementation of this functionality and applied that rendering parameter template on each component rendering. While reading these values, If I checked the Checkbox IsComponentVisiable it returns "1" and unchecked the Checkbox, it returns me null. var flag= RenderingContext.Current.Rendering.Parameters["IsComponentVisible"] I was surprised about its behaviour that instead of "0" it returns null? I raised the support ticket to Sitecore to understand that am I doing something wrong or if it's the default behaviour of the checkbox field when we use it as the rendering parameter? Sitecore suggested: Find below the Sitecore Team Response on my Ticket: Based on the provided information we would like to define the scope of the current case: Issue def

URL Redirects Module in Sitecore

Image
In one of my projects, my client's requirement was to implement the URL Redirect feature from his existing SharePoint website to the New Sitecore website. My client suggested the "Constellation.Feature.Redirects"  Redirect module to accomplish the functionality.  In this blog, I am giving insight on this module installation, what features I have used and the challenges I have faced during implementation. I want to give a huge thanks to Richard Cabral aka Sgt Sitecore who guide and helped me with the implementation. Installation: To install the URL redirect module please find below the link in which all the steps are mentioned in detail:  Constellation.Feature.Redirects Steps: Constellation.Feature.Redirects are managed via NuGet. In Visual Studio, fire up the Package Manager console and install it into a Web Application project: PM:> Install-Package Constellation.Feature.Redirects After installation, you must build an

Pipeline Profiling Processors

Image
Pipeline: It’s a sequence of processes that executes in a defined order to perform the task into Sitecore. In Sitecore, there is a number of inbuild pipelines and we add our custom pipelines into that. We can change the order of the pipelines as per our requirements. When we write our custom pipelines then it’s difficult to find out on deployment environment that it's executing or not. To check the sequence of execution there is a good feature provided by Sitecore is the Pipeline Profiler. The pipeline admin page is used to view all the pipeline processors that are defined into the Sitecore and the sequence in which they will execute. By default, The pipeline Profiler page is disabled, and you need to enable it manually. To enable Pipeline profiling, perform the below listed steps: Add the following key <add key="env:define" value="Profiling" /> to Web.config <appSettings> section. Login into the Sitecor

Unit Test for Sitecore Custom Personalization Rule

Image
I assume that in your career path you all become chance to hands on implementation for Sitecore Custom Personalization Rule. If you did not, then I have already described in detail about Custom Personalization Rule implementation in my one of previous blog. See the Blog Post: Custom Personalization Rules in Sitecore Today I am going to share with you about implementation of Unit Test for Custom Personalization Rule. Custom Personalization Rule business logic: protected override bool Execute(T ruleContext) { if (_pageContext != null && !string.IsNullOrWhiteSpace(_pageContext.baseketValue)) { var deliveryType = _basketDetailsService.GetBasket(_pageContext.basketValue).deliveryType; if (deliveryType != null && deliveryType== DeliveryType.CashOnDelivery) { return true; } } return false; } In above sample piece of code, I have created two Serv

Sitecore Custom EXM Unsubscribe Page

Image
If you ever got a chance to implement the email campaign functionality using the default email template in EXM, then you may have observed that each email send to the users contains two links that are Unsubscribe and Unsubscribe from all from future emails campaigns. Requirement: When the user clicks on the Unsubscribe link in the email, instead of redirecting it to Unsubscribe.aspx page which is the default, the user should land on the custom page developed into the Sitecore. On the custom page, the user can choose the options from which list the user wants to unsubscribe. Solution: When the user clicks on the unsubscribe link, Sitecore default redirects to the RedirectUrlPage.aspx with decrypted query string parameter named ec_eq . The ec_eq query string parameter is the encrypted query string, and it is handled by the RedirectUrlPage.aspx process which handles the decryption of those parameters and returns Contact ID, Message-Id and others. On

Sitecore Geolocation Service API

Image
 Sitecore provides location details of the user using Sitecore Geolocation API . It gives the detail of the Time zone, City, IP Address, region, Country, Post Code, Longitude and Latitude, etc. It is advantageous for marketers or developers in terms of visitor information, tracking, and personalization.  Using this information, you can apply the personalization rules for different geographical locations, tracking goals and page events. In this blog, I will let you know about How to enable the Sitecore Geolocation Service API and by using this API fetch the details of the user location using an IP Address. Enable Sitecore Geolocation Service API: First, you need to raise a request to Sitecore to activate the Sitecore IP Geolocation service. For the same, you can refer to Sitecore Documents. See the document: Set up Sitecore IP Geolocation Retrieve Geolocation Data: First, you need to make sure that XB and Analytics tracker is work

Execute PowerShell Script with Sitecore Scheduler

Image
If you have a requirement like execute PowerShell script in form of a scheduler then Sitecore Scheduler provides an option for the same. For Example, you want to delete some Sitecore Items after a specific date or remove the ideal user at some specific time. For that, you have written a PowerShell script instead of C# code and you want to schedule the PowerShell Script with a Scheduler. Then Sitecore Scheduler provides you a good option to execute PowerShell Script. If you want to know How to Install the PowerShell module with your Sitecore instance and the ideas about the PowerShell command and Scripts then, please refer series of blog posts written on: PowerShell with Sitecore . Here I am giving you an example to create a Sitecore Item using PowerShell Script and Schedule that Script by Sitecore Scheduler. You can update your PowerShell script as per your requirement. Step 1: Go to the PowerShell ISE, you can open it by Sitecore Launchpad or