Tuesday, March 26, 2019

Sitecore Powershell Script for Returning Users and Email Addresses in a particular Role

Here's a quick powershell script to return names and email address of users in a particular role in your sitecore instance. The ListView allows you to save the results of the query in excel, csv, etc.

$listOfUsers = Get-RoleMember -Identity "Role name"
$output = @()
ForEach($user in $listOfUsers) {
    $output += New-Object PSObject @{Name = $user.Name;  Email = $user.Profile.Email}
}
$output | Show-ListView -Property Name,  Email

Tuesday, December 4, 2018

Sitecore DB Locks

Following info is from:https://briancaos.wordpress.com/2014/10/23/sitecore-eventqueue-deadlocks-how-to-solve-them-and-how-to-avoid-them/

Sometimes database locks happen in Sitecore. This results in spinning and spinning. To check, go to your db and use the following query:

SELECT
db.name DBName,
tl.request_session_id,
wt.blocking_session_id,
OBJECT_NAME(p.OBJECT_ID) BlockedObjectName,
tl.resource_type,
h1.TEXT AS RequestingText,
h2.TEXT AS BlockingTest,
tl.request_mode
FROM sys.dm_tran_locks AS tl
INNER JOIN sys.databases db ON db.database_id = tl.resource_database_id
INNER JOIN sys.dm_os_waiting_tasks AS wt ON tl.lock_owner_address = wt.resource_address
INNER JOIN sys.partitions AS p ON p.hobt_id = tl.resource_associated_entity_id
INNER JOIN sys.dm_exec_connections ec1 ON ec1.session_id = tl.request_session_id
INNER JOIN sys.dm_exec_connections ec2 ON ec2.session_id = wt.blocking_session_id
CROSS APPLY sys.dm_exec_sql_text(ec1.most_recent_sql_handle) AS h1
CROSS APPLY sys.dm_exec_sql_text(ec2.most_recent_sql_handle) AS h2
GO

The blocking_session_id is the session id that causes the deadlock. You need to kill the blocking session. Run the kill command in the SQL Management Studio:
1
2
kill 205;
kill 62;
Voila, the deadlock is gone.

Wednesday, October 17, 2018

How to Add Anchor Link to General Link

I came across an issue where we needed the general field in Sitecore 8.2 to also have an anchor added to it, so that the page loads to a particular section on the page. Unfortunately, it's not as easy as you would think! I found the solution here:

https://community.sitecore.net/developers/f/8/t/1785

Basically, you have to put the field in "Raw Values" mode, then within the link displayed in the general field, make sure to modifyed the "anchor=" attribute to include whatever you'd like the anchor to be, minus the hashtag. 

Thursday, July 12, 2018

Sitecore Experience Editor Mods in MVC

Normally in Sitecore you need an EditFrame to handle editing of Droplists in the Page editor. This however is not supported in MVC by default, but there's a great post here on how to get it working:
Alternatively you can set a 'custom experience button' to enable editors to change the droplist value when in the Page editor:
To set this up follow these steps:
  1. Change to Core database
  2. Create a new item under /sitecore/content/Applications/WebEdit/Custom Experience Buttonsusing the template /sitecore/templates/System/WebEdit/Field Editor Button
  3. In this new item, set the value of the 'Fields' field to the name of your templates DropLink field (also set appropriate icon/header/tooltip field values)
  4. Go back to the master database
  5. Select your sublayout/rendering and in the field 'Page Editor Buttons' select your newly created button item.
Once this is setup when you edit the component and click the button editors will be able to change the value for the droplist.

Wednesday, July 12, 2017

Creating Custom Fact Table in Sitecore

Here's how you can record page events and put them into the reporting table in Sitecore.  Followed these steps and it was quite easy!

https://www.onenorth.com/blog/post/sorting-sitecore-items-by-popularity-using-sitecore-analytics

One thing to remember to ensure that you include the VisitorIdentification function in the layout you're using or your page events may not record correctly.