Posts

Showing posts from October, 2011
My new blog present here.

Featured Post

Insights into Sitecore Search: A Definitive Introduction

A key component of digital experience management is effective information retrieval. A simplified approach is required for websites, applications, and platforms containing a lot of material so that consumers can easily get the data they require. This need is met by Sitecore, a well-known name in the field of digital experience platforms (DXPs), which provides powerful and comprehensive search functionality. We will travel into the realm of Sitecore Search in this article, learning about its capabilities, architecture , and the enormous value it offers both developers and end users. Introduction to Sitecore Search    A headless content discovery platform powered by AI , Sitecore Search enables you to build predictive and custom search experiences across various content sources. To extract and index you

Get UserProfile Object of Logged-in User

In this article, I will explain how to get UserProfile object for Logged-in User (current user). //Function Call UserProfile objUserProfile= GetProfileOfCurrentUser(SPContext.Current.Web.CurrentUser.LoginName) public UserProfile GetProfileOfCurrentUser(string accountName) { UserProfile profile = null; try { if (string.IsNullOrEmpty(accountName)) { return null; } SPSecurity.RunWithElevatedPrivileges(delegate() { SPSite site = SPContext.Current.Site; ServerContext context = ServerContext.GetContext(site); UserProfileManager profileManager = new UserProfileManager(context); if (!profileManager.UserExists(accountName)) { profile = null; } profile = profileMan

Event receiver to update an item's in list

How to update Created By and Modified By fields in sharepoint list using C# In this article I will explain, how to update list item in event receiver. In event receiver, I will update Created By /Modified By/Title metadata of list item. Code: public override void ItemUpdated(SPItemEventProperties properties) { int userID=0; string userNTID = "WIN\AMITKUMAR"; SPSecurity.RunWithElevatedPrivileges(delegate() { SPListItem CurrentItem = properties.ListItem; CurrentItem.Web.AllowUnsafeUpdates = true; CurrentItem.Web.Site.AllowUnsafeUpdates = true; // In the next statment i am updating CreatedBy(Author) filed with SystemAccount CurrentItem["Author"] = CurrentItem.Web.Site.SystemAccount.ID; //CreatedBy //We can also update CreatedBy(Author)/ModifiedBy(Editor) field with Any user account FindUserIDByNTID(userNTID, CurrentItem.Web.Site, ref userID);

Get unique value from Array (String/Integer):

Problem: In one of my project, I am getting values from one datasource in the form of .net Array. In the .NET Framework 3.5 there is a function called Distinct(). This Distinct() function return unique values from Array. This function works fine in the case of integer array. In string array, it not able to handle case sensitivity. If all items in the string array in same case, then it will work fine. Due to this, I was facing problem in getting unique value from String Array. Resolution: To Solve this problem, I have created functions, which used Stringcomparison. InvariantCultureIgnoreCase. .NET Framework 3.5: It is one line of code. //If integer array int [] intArr={5,2,3,3,5}; intArr = intArr.Distinct().ToArray(); // Output : intArr ={5,2,3} //If string array string [] strArr={“Amit”,”Amit”,”Kumar”,”Kumar”}; strArr = strArr.Distinct().ToArray(); //Output: strArr ={“Amit”,,”Kumar” } string [] strArrCase={“Amit”,”AMIT”,”Kumar”,”KUMAR”,”Amit”,”Kumar”}; strArrCa