I have written a nifty little tool in PowerShell that eases the deployment of SharePoint solutions (WSP) files. The tool serves as a management tool for new features. It uses an XML configuration to select a bunch of solutions and deploys them to the farm. Now, despite our best intentions and the best efforts of QA, we somehow manage to upload solutions that do not do exactly what they are supposed to do, or – horror of horrors – even disrupt previous behavior.
So, the tool is also used to restore the site to its previous glory. It is actually a breeze to do so. You just change the purpose to “restore” and point to the backup directory created at the time you “Deploy”ed.
I think that I’ll eventually publish the code in CodePlex, but here is the purpose of this blog: I needed to store the old version of the solutiion in the backup directory and used the Name property of the Get-SPSolution. WRONG!! the Name property appends a naughty prefix – “SPSolution Name=” -to the real name – see the screen shots below:


Instead you should use the filename.
That’s All Folks!!
Relative and absolute URLs in CEWP
Microsoft’s own explanation of the CEWP in:http://office.microsoft.com/en-us/sharepoint-server-help/content-editor-web-part-HA010024046.aspx includes the following caveat:
Note: If you enter a URL into the Content Editor Web Part as a relative link, the link converts to an absolute URL when the entry is saved. This automatic conversion can be an issue if you are deploying content from a staging environment to production, where absolute URLs reference the original server's name. To address this automatic conversion issue, you will need to edit the Content Editor Web Part on the production server and update the URLs manually.
Can anything be done about it? How about thinking out of the box? No it’s not the same as OOTB – requiring no coding. It is out of the box that we are usually stuck in by our common education, the blinders that society puts on our eyes. It ought to be named “out of the rut” or OOTR.
So here is the OOTR solution. Put the CEWP HTML in a text file, relative URL included and put it in a document library. Put the link to this text file in the CEWP. Now when you move from one environment to another, as long as the structures of the environments are the same – namely they have the same relative navigation – the conversion will be done without reediting the web parts.
This approach offers an additional advantage. When a specific CEWP is deployed in multiple pages, the HTML is kept in one location. Any future changes will be done ONCE in this central location rather than the painful and error prone approach of editing the CEWP in every page.
The long and the short of is: CEWP content belongs in a text file and kept in a SharePoint library! The CEWP itself will only have the link to this text file, and no HTML of its own!
That’s all folks
Yesterday I had the pleasure of meeting Chris malavarca who is an account executive for Matalogix. The name Metalogix immediately brought me to think about language and meta-language, rule and meta-rule, and the dangers of mixing between them.
Alan Turing envisioned a machine with states, code and an infinite tape. The tape could be in any of infinite positions and be made to move forwards or backwards, the machine could be in any of a finite number of states. The code was a finite transition table that determined how the machine moved from state to state depending on the current input from the tape and the current state. Obviously the Universal Turing Machine separated the input or data from the code.
John Von Neumann came with the idea that both program and data will share a common memory. This is the architecture of the modern computer.
We can go into years of discussions of what all of this really means and of defining what are the limits of computation, but I am too slow a typist to be able to do all this. I want to concentrate on one of the problems that such an architecture presents – the problem of un-stratified control. If program and data share the same space and the program manipulates the data, what will prevent the program from manipulating itself? Indeed one of the early procedural languages – the ubiquitous COBOL - had an ALTER instruction by which the programmer could change a GOTO command so its next branch will no longer be to A but B (or C, or D…). This created a multitude of problems and rendered debugging close to impossible. You can only imagine how our modern day hackers would have enjoyed such capabilities (they actually do, but this is another story preserved for another day). In short we needed to do something about it, and we did. We strongly separate program and data.
A similar separation in logic helps a great deal. Here is a case in point. How many times have you heard, or, horror of horrors, said: “This is the exception that proves the rule,” or “There is no rule without exceptions.” Is it really so? If there is no rule w/o exceptions than this rule must have its exceptions as well – so there is a rule w/o exceptions! Oops – a paradox. Turn it in your head and scratch to the brink of baldness, you still cannot resolve this paradox unless… Unless you stratify controls! So how do we do this? We declare the rule “There is no rule without exceptions” To be a meta-rule; A rule about rules, but itself above the rules that it regulates. Itself the program, the other rules the data. Do this and the paradox will evaporate. So if rules are Logix, this rule is Metalogix!
I doubt if the founders of Metalogix had this in mind, but it sure is a nice name!
Have you ever noticed that after adding a web part – any web part - to the page, we lose the ribbon and the “list Tools” tab.
Well, I wracked my tired and only semi-aware brain, tore my thinning hair, bit my nails and even “googled” it to no avail.

A little serendipity helps a great deal! I just happened to click in the original list web part (not the added web part) and voila, as if by magic, the tab and ribbon re-appeared!

That’s All Folks
In my previous blog about the subject I observed that after adding a web part – any web part - to the page, we lose the ribbon and the “list Tools” tab.
Today, upon revisiting my list, I discovered that the problem does not go away. When I clicked on the list and got to the page, the “list tools” tab was still missing.
Again, I clicked anywhere in the list web part – this time in the empty space to the right of the “Add New Item” – the missing tab and ribbon returned.
This is a persistent behavior. Even now, after clicking the list in the breadcrumbs or the left panel, the list is re-rendered sans the extra tab. You’ll have to do the extra-click ever again!
That’s All Folks
in a previous blog about the idiosyncrasies of calculated fields, I used the the default KPIs.
"/_layouts/images/kpidefault-2.gif" is the Red KPI
"/_layouts/images/kpidefault-1.gif" is the Yellow KPI
"/_layouts/images/kpidefault-0.gif" is the Green KPI
This was then, in the days of SharePoint 2007.
Nowadays, in SharePoint 2010, they moved them a little. Their new home is the Template directory. so here is the new arrangement:
"/_Template/images/kpidefault-2.gif" is the Red KPI
"/_Template/images/kpidefault-1.gif" is the Yellow KPI
"/_Template/images/kpidefault-0.gif" is the Green KPI
That’s All Folks
Bug or Feature?
© 2012 By: Dov Trietsch. All rights
reserved.
I was born in a time and place where avant-garde accountants used a
handle-powered adding machines, old-fashioned ones still used pencil and paper,
and all used their heads. As a child I did most of my calculations mentally and
reverted to paper and pencil only for the really tough ones. As a young
statistician I did most of my calculations on an Electro-mechanical calculator
which had the ability to do the sum of x while computing the sum of
x2. This feature on my "Facit" really facilitated my work because the
two sums are needed to compute the average and standard deviation.. I also
learned to program computers, but I still do most calculations in my head.
When my daughter started elementary school, the HP hand-held scientific
calculator was two years old and K&E stopped making slide
rules. When she reached second grade, TI released its "Professor" – an owl
shaped hand-held calculator that could also be used to give a child an
arithmetic quiz. Almost every kid in her class owned one of these owls and she
wanted one badly. Like a banker who’ll only lend money to those who don’t need
it, I refused her. "When you know your arithmetic down pat," I said "and need to
do really complex computations, I’ll buy you one." Seven years later, for her
honors physics lab, I bought her a programmable scientific calculator. Ours, I
am proud to say, was a Spartan home. We still don’t have cable TV, we never had
any video games and for her personal computer our daughter had to program her
own games. She realized, after successfully programming her first Dungeons and
Dragons game that she does not particularly like programming, but she was
exposed to the art at a very young age and her computer generated game scenarios
always drew a crowd of youngsters to our home.
Yesterday, contrary to my habits, I used the Windows' Calculator and out of curiosity used the
various keys and buttons. One such button - Int - calculates
the integer part of a number. Its inverse - Frac calculates
the fractional part. Again, out of curiosity, I tried them both on the number
(-5.7). The results were -5 and -0.7 respectively. For 5.7 the result were 5 and
0.7 respectively. This is wrong! Worse, most of today’s young adults, who never
mastered arithmetic (because they owned a "professor" or a similar crutch), use
the Windows Calculator as a gospel. To them it must be right.
Why is it wrong? The Int function returns the highest integer that is lower
or equal to a number. Int(5.7) is indeed 5. Int(-5.7) is (-6). (-5) is greater
than (-5.7). The fractional part is even more complex. Again for 5.7 the result
is indeed 0.7. For (-5.7) the result is 0.3. Yes 3/10ths! Why? The sum of
integer and fraction make the number. 5 + 0.7 = 5.7. Similarly (-6) + 0.3 =
(-5.7).
Even at Microsoft they know better. Here is How Excel applies the INT
function: =INT(-5.7) returned the correct answer of
-6. Excel does not have the Frac function so
it could not be tested.
I first noticed this bug in the good old days of Win 3.1.
During the years, I have revisited the calculator now and then. At least 17
years have passed. Operating systems came and went. We are now using Windows 7
(8 is just around the corner), but the Int nad
Frac error persists. By now it had become a tradition and we
all know that tradition is stronger than science. When will they ever
learn?!
That's All Folks
Highlighting a Managed Application
As you search (Google is better, because Bing lacks BANG!!) for existing solutions for SharePoint Central Admin tasks You are usually instructed to highlight one app or another, or one web app or another. Nobody tells you how to achieve this task, but on occasion you scratch your head in puzzlement. You click on the app and some window opens, but you actually wanted the ribbon. Scratch your head no longer! Here is what needs to be done.
Just click on the line under the “type” column. Clicking under name sometimes gets you to the ribbon and sometimes gets yoy to the management of the app. Clicking in the type column always gets you to the ribbon. BTW, once in the active ribbon, click manage if you want to manage the app.
The example below shows how I did it with the “Business Data Connectivity” app.
PS – the same applies almost everywhere in SharePoint 2010, not just Central Admin.
That’s All Folks!
Renaming SharePoint service app databases
When you install SharePoint 2010 and use the wizards, you will be asked which services you’d like to install. By default all but Lotus-Notes-Connector are preselected. SharePoint will install the services and assign a plethora of databases to serve these services.
Alas, horror of horror, all these databases are named by Microsoft and all end with GUIDs. DBAs and other keepers of standards abhor it. Sometimes they even go a step further and want the DB names to conform to some esoteric naming convention or another, so they demand (and we the meek comply) that the DB names will be changed.
Here we (the meek) will save ourselves tons of work by being more selective. Instead of ‘wizardly’ creating apps and databases – databases that we later must rename, let us select just what we need but need not later change. So tick all the apps off except: Access Services, Excel Services, Application Registry, Admin Content, and Search. The first two have no associated DBs, the next two have ‘guided’ DB that we cannot change or affect – which means that even the strictest of the DBAs has no choice but to live with it, and Search because changing its database names (yes names, 3 of them) is bordering on the impossible – probably on the wrong side of the border.
You may create the services by using Central Admin or by using PowerShell, but I am not going into how this is done. In here I am only going to speak about handling the Search app and its databases.
I was asked to do the database renaming by a client. Luckily we agreed on a T&M approach or I would have lost my pants – possibly even my underwear. I came after the fact and immediately ‘googled’ for solutions. (Why didn’t I use Bing? Because Bing has no Bang!!). The best article I found was:
http://technet.microsoft.com/en-us/library/ff851878.aspx
This article guided me more or less w/o any events until I tried to follow its advice about search. More or less because what they forgot to tell you was not to rename all the databases. Instead you’ll do much better if you rename them one-by-one and just before you do a step. So be warned. Again, you are better off creating the apps already with the right database names, but I digress. Following the article’s advice with the Search app simply does not work. Worse than that, renaming the search databases in SQL Server opens a Pandora’s Box. You’ll get stuck with a Search app that does not work and that you cannot remove, at least not in CA or in PowerShell.
To remove the now ‘offended’ and offending app, you must get its id – in CA go to Manage Service Apps, right click on the Search and copy shortcut. The last piece of the shortcut is the app’s id in a form of – you guessed it – a GUID. Now go to the bin directory of the 14 hive and use the following STSADM command:
Stsadm -o deleteconfigurationobject -id
97s2fgd9-453k-3423-f334-8r78jd3bv2t6
replace the
yellowed GUID
with your own.
So now that you don’t have a Search app, you can create it and control the DB name to boot. How? Use the script below, but set the first five variables to reflect your own set of servers and database name.
## Parameters used
## change the variables below to your own servers and naming conventions
$databaseServerName = "shrpt-db-server"
$searchServerName = "shrpt-apps-server"
$searchSAName = "Search Service Application"
$saAppPoolName = "SharePoint Web Services Default"
$searchDBName = "Search_Services_Application_DB"
## First remove the old search
## This will require an id - namely a guid so get the service guid before doing this
$spapp = Get-SPServiceApplication -Name $searchSAName
Remove-SPServiceApplication $spapp -RemoveData
##START SEARCH
Write-Host "Creating Search Service and Proxy..."
Write-Host " Starting Services..."
Start-SPEnterpriseSearchServiceInstance $searchServerName
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $searchServerName
Write-Host " Creating Search Application..."
$searchApp = New-SPEnterpriseSearchServiceApplication -Name $searchSAName -ApplicationPool $saAppPoolName -DatabaseServer $databaseServerName -DatabaseName $searchDBName
$searchInstance = Get-SPEnterpriseSearchServiceInstance $searchServerName
Write-Host " Creating Administration Component..."
$searchApp | Get-SPEnterpriseSearchAdministrationComponent | Set-SPEnterpriseSearchAdministrationComponent -SearchServiceInstance $searchInstance
##Crawl
Write-Host " Creating Crawl Component..."
$InitialCrawlTopology = $searchApp | Get-SPEnterpriseSearchCrawlTopology -Active
$CrawlTopology = $searchApp | New-SPEnterpriseSearchCrawlTopology
$CrawlDatabase = ([array]($searchApp | Get-SPEnterpriseSearchCrawlDatabase))[0]
$CrawlComponent = New-SPEnterpriseSearchCrawlComponent -CrawlTopology $CrawlTopology -CrawlDatabase $CrawlDatabase -SearchServiceInstance $searchInstance
$CrawlTopology | Set-SPEnterpriseSearchCrawlTopology -Active
Write-Host -ForegroundColor white " Waiting for the old crawl topology to become inactive" -NoNewline
do {write-host -NoNewline .;Start-Sleep 6;} while ($InitialCrawlTopology.State -ne "Inactive")
$InitialCrawlTopology | Remove-SPEnterpriseSearchCrawlTopology -Confirm:$false
Write-Host
##Query
Write-Host " Creating Query Component..."
$InitialQueryTopology = $searchApp | Get-SPEnterpriseSearchQueryTopology -Active
$QueryTopology = $searchApp | New-SPEnterpriseSearchQueryTopology -Partitions 1
$IndexPartition= (Get-SPEnterpriseSearchIndexPartition -QueryTopology $QueryTopology)
$QueryComponent = New-SPEnterpriseSearchQuerycomponent -QueryTopology $QueryTopology -IndexPartition $IndexPartition -SearchServiceInstance $searchInstance
$PropertyDatabase = ([array]($searchApp | Get-SPEnterpriseSearchPropertyDatabase))[0]
$IndexPartition | Set-SPEnterpriseSearchIndexPartition -PropertyDatabase $PropertyDatabase
$QueryTopology | Set-SPEnterpriseSearchQueryTopology -Active
## Proxy
Write-Host " Creating Proxy..."
$searchAppProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$searchSAName Proxy" -SearchApplication $searchSAName > $null
#####END SEARCH
That’s All Folks!