Reporting stops working after upgrading from Service Manager 2012 SP1 to R2

After upgrading Service Manager 2012 from SP1 to R2 Reporting stops working.
 
Looking at Data Warehouse - Data Warehouse Jobs in the Service Manager Console some of the jobs are listed as Failed, amongst them, Load.Common, Load.OMDWDataMart and Load.CMDWDataMart.
 
After a great deal of Googling I came across this site:
 
http://technet.microsoft.com/en-us/library/dn299381.aspx
 
Stating the it's a known issue and that all you need to do is to run a SQL-script against 4 databases on the Data Warehouse server.
 
The databases are:
 
- DWRepository
- DWDataMart
- CMDWDataMart
- OMDWDataMart
 
The script:
 
IF OBJECT_ID('tempdb..#PKFixQueries') IS NOT NULL
    DROP TABLE #PKFixQueries

;WITH FactName
AS (
        SELECT  w.WarehouseEntityName
        FROM    etl.WarehouseEntity w
        JOIN    etl.WarehouseEntityType t ON w.WarehouseEntityTypeId = t.WarehouseEntityTypeId
        WHERE   t.WarehouseEntityTypeName = 'Fact'
),FactList
AS (
    SELECT  PartitionName, p.WarehouseEntityName
    FROM    etl.TablePartition p
    JOIN    FactName f ON p.WarehouseEntityName = f.WarehouseEntityName
)
, FactWithPK
AS (
    SELECT  f.WarehouseEntityName, f.PartitionName, b.CONSTRAINT_NAME, a.COLUMN_NAME
    FROM    FactList f
    JOIN    INFORMATION_SCHEMA.KEY_COLUMN_USAGE a ON f.PartitionName = a.TABLE_NAME
    JOIN    INFORMATION_SCHEMA.TABLE_CONSTRAINTS b ON a.CONSTRAINT_NAME = b.CONSTRAINT_NAME AND b.CONSTRAINT_TYPE = 'Primary key'
)
, FactWithDefaultOrNoPK
AS (
    SELECT  DISTINCT f.WarehouseEntityName, f.PartitionName
            , 'PK_' + f.WarehouseEntityName AS DefaultPKConstraint
            , 'PK_' + f.PartitionName AS NewPKConstraint
    FROM    FactList f
    LEFT JOIN    FactWithPK pkf ON pkf.WarehouseEntityName = f.WarehouseEntityName AND pkf.PartitionName = f.PartitionName
    WHERE   pkf.WarehouseEntityName IS NULL OR pkf.CONSTRAINT_NAME = 'PK_' + f.WarehouseEntityName
)
, FactPKList
AS (
    SELECT  DISTINCT f.WarehouseEntityName, f.COLUMN_NAME
    FROM    FactWithPK f
)
, FactPKListStr
AS (
    SELECT  DISTINCT f1.WarehouseEntityName, F.COLUMN_NAME AS PKList
    FROM    FactPKList f1
    CROSS APPLY (
                    SELECT  '[' + COLUMN_NAME + '],'
                    FROM    FactPKList f2
                    WHERE   f2.WarehouseEntityName = f1.WarehouseEntityName
                    ORDER BY COLUMN_NAME
                    FOR XML PATH('')
                ) AS F (COLUMN_NAME)
)
SELECT  f.PartitionName,
        '----------------------------- [' + f.PartitionName + '] -----------------------------' + CHAR(13) +
        'IF OBJECT_ID(''[' + f.DefaultPKConstraint + ']'') IS NOT NULL' + CHAR(13) +
        'BEGIN' + CHAR(13) +
        '  ALTER TABLE [dbo].[' + f.PartitionName + '] DROP CONSTRAINT [' + f.DefaultPKConstraint + ']' + CHAR(13) +
        'END' + CHAR(13) + CHAR(13) +
        'IF OBJECT_ID(''[' + f.NewPKConstraint + ']'') IS NULL' + CHAR(13) +
        'BEGIN' + CHAR(13) +
        '  ALTER TABLE [dbo].[' + f.PartitionName + '] ADD CONSTRAINT [' + f.NewPKConstraint + '] PRIMARY KEY NONCLUSTERED (' + SUBSTRING(pk.PKList, 1, LEN(pk.PKList) -1) + ')' + CHAR(13) +
        'END' AS Query
INTO    #PKFixQueries
FROM    FactWithDefaultOrNoPK f
JOIN    FactPKListStr pk ON pk.WarehouseEntityName = f.WarehouseEntityName

DECLARE @PartitionName NVARCHAR(MAX), @Query NVARCHAR(MAX)
WHILE EXISTS (SELECT 1 FROM #PKFixQueries)
BEGIN
    SELECT  TOP 1
            @PartitionName = PartitionName,
            @Query = Query
    FROM    #PKFixQueries

    PRINT   @Query
    EXEC(@Query)

    DELETE  #PKFixQueries
    WHERE   PartitionName = @PartitionName
END
 
After running the script against these 4 databases, start the jobs in the Service Manager Shell using the command Start-SCDWJob -JobName Load.Common -ComputerName <dwservername>. You will see the BatchId and StartTime being updated after running the jobs. Use Get-SCDWJob -JobName Load.Common -ComputerName <dwservername> to get information about the jobs.
 
 

Missing Scroll Bar SCSM 2012 Portal

Add the following style sheet to the SMPortalPage.master to solve this issue:
 
<style>
body.v4master {
                height:inherit;
                width:inherit;
                overflow:visible!important; //!important to override the original theme.
}

body #s4-workspace {
                overflow-y:auto !important;
                overflow-x:auto !important;
                height:auto !important;
}
</style>

 

Source: http://blogs.technet.com/b/servicemanager/archive/2012/07/05/fixing-the-missing-scroll-bar-issue-on-the-scsm-2012-portal.aspx


Service Manager - Subscription templates sends e-mail in wrong language

We've been looking for a solution to why the subscription template configured as English (United States) sends out e-mails in Swedish.
 
It's pretty basic actually. If the locale variable is not set in Active Directory, the locale field on the user will be empty in Service Manager. Our guess is that SCSM then will base this upon the country variable, which in my case is Sweden. And since we want all e-mail correspondence in English we need to set the locale to English (United States) for all users.
 
To do this, we are creating a management pack with a powershell script scheduled to run once per day. For more information regarding this management pack and powershell script, please see the following links:
 
Powershell Script

Import-Module smlets ; Add-PSSnapIn SMCmdletSnapIn ;

 

#Delete the existing data from the CSV Clear-Content -Path "E:SMAdminCSVUsers.csv"

 

#retrieve all users from the CMDB and cycle through them

$users = (get-scsmclass Microsoft.AD.User$ | get-scsmobject)

foreach ($user in $users)    

{        

$UserName = $user.UserName               #get the username, used to identify the person        

$Domain = $user.Domain                   #get the domain, this is required for a CSV import        

$ID = $user.ID                           #get the users guid, we will use this to create the ID for the settings object         $setPref = 'Pref.'                       #used as a prefix for the localsetting object id        

$setID = $setPref,$ID                 

$setID = [string]::join('',$setID)       #combine the users guid and Pref. to make the id for localesettings        

if ($user.City -like "Shanghai") {$timezone = 'China Standard Time'}        

elseif ($user.City -like "Dhaka") {$timezone = 'Central Asia Standard Time'}        

else {$timezone = 'W. Europe Standard Time'}        

$locale = '1033'                         #setting the locale, in this case it's English (United States)        

$data = $UserName, $Domain, $setID, $timezone, $locale  #put it all into an array        

[string]::join(',',$data) | ForEach-Object {Add-Content -Value $_ -Path "E:SMAdminCSVUsers.csv"};   #convert the array to a string and append to the csv

}

 

#once all users have been added to the csv, import it into the CMDB using the xml mapping file.   

Import-SCSMInstance -DataFileName "E:SMAdminCSVUsers.csv" -FormatFileName "E:SMAdminCSVUserImport.xml"

 

#Remove any automatically created localization settings, the script has create new ones for everybody

get-scsmclass System.UserPreference.Localization$ | get-scsmobject -filter {DisplayName -notlike "%-%"} | remove-scsmobject -force

 

Remove-PSSnapIn SMCmdLetSnapIn;

Remove-Module smlets;

 

Source: http://scservman.wordpress.com/2010/12/05/setting-locale-and-timezone-in-bulk/
 
Management Pack
http://blogs.technet.com/b/servicemanager/archive/2009/12/21/creating-an-ad-connector-using-powershell-and-csv-import.aspx

RSS 2.0