Tuesday, 17 July 2007

Creating a New My Sites or adding My Sites to a Moss Portal
The other day I had to add My Sites to a client Moss Site

Firstly create a My Sites Web Application
Central Administration > Application Management > SharePoint Web Application Management:
Create or extend Web application

Then create a My Site Host Site Collection
Central Administration > Application Management > SharePoint Site Management:
Create site collection
Remember to set the site template as Enterprise>My Site Host

Now add a managed path if you don’t plan to use Sites as your location
Central Administration > Application Management > SharePoint Web Application Management:
Define managed paths
Add your Location as a wildcard path.
Next go in to your SSP
User Profiles and My Sites: My Site settings
Change the
Personal Site Services: to your new Web Application
And change
Personal Site Location: to your new location you defined earlier

And there you have it a new My Sites.

Monday, 9 July 2007

Adding Google as a search scope

Well the title is prehaps miss leading but you can trick MOSS in to using Google as a search scope.

Firstly how do we get google working with in a Moss site
As Google is droping thier Web service api (which was limated to 1000 quires a day) and are promoting thier Ajax API i will describe how to use the Ajax API.
We will use a CWEP (Content Editor Web Part) and drop some custom code in to the Source section.

<link href="http://www.google.com/uds/css/gsearch.css" type="text/css" rel="stylesheet">
    <script src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0&key=REPLACE_ME" type="text/javascript"></script>
    <script language="Javascript" type="text/javascript">
    //<![CDATA[     function OnLoad() {       // Create a search control       var searchControl = new GSearchControl();       // Add in a full set of searchers       searchControl.addSearcher(new GwebSearch());       searchControl.addSearcher(new GvideoSearch());       searchControl.addSearcher(new GblogSearch());       searchControl.addSearcher(new GnewsSearch());       searchControl.addSearcher(new GbookSearch());              // draw in tabbed layout mode       var drawOptions = new GdrawOptions();       drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);       searchControl.draw(document.getElementById("search_control_tabbed"), drawOptions);       // Execute an inital search       searchControl.execute(cleanup(getQval("k")));     }     GSearch.setOnLoadCallback(OnLoad);     //]]>
    function cleanup(str)
      str = str.replace(/%22/ig, "\"");
      str = str.replace(/\+/ig, " ");
      str = str.replace(/%20/ig, " ");
      str = str.replace(/%2B/ig, "+");
      return str;
function getQval(name)
var m, Q = window.location.search.substring(1);
if ('' != Q)
var re = new RegExp(escape(name) + '=([^&$]+)');
if (m = Q.match(re))
return m[1];
else return '';
return '';

<div class="search-control" id="search_control_tabbed">Loading</div>
<div id="error"></div>

Replace the REPLACE_ME with your google API key which you can get here
NOTE espaly for corprate clients they must read and approve of the tearms and conditions in relation to Google's API key

The Google part of the code is in the OnLoad()
and you should be able to easly modfy it to your own needs just explor the API

the rest of the fuctions are there to tokenise the URL string so make the search work from a search scope
the cleanup(str) fuction is used to reformat the URL token in to plain text.

the getQval(name) Gets the url tokens for the search string. Since i am just lazy and not much of a javascript programer this is just a cut and past from this Forum all credit goes to RobB and Michael Winter.

now you have a google search webpart
go to the Search colection in your portal
Add two pages one for Google Search and one for Google Search Results.
Add these pages to the relative tabs.
Drop a Cwep whith the above code.
you now have a search page and a results page that contain a Google search web part

now how to get Moss search scopes to point the results here

go to search scopes ehter in the SSP or at the toplvl of the site colection(recomended for this method)
Create a display groop and call it Google Search Group (or your own name)
Creat a search scope called Google Search that is atached to Search Dropdown and Google Search Group that uses a custon search results page. Point to your newly created Google search results Page were you added the Cwep.

add a rule that will not search anywere (point it to the google search page you created for a minimal search)

now you will have a google search in your defauld search dropdown and any search placed in there will open your Google Search Results page which will display the search results in the Cwep.

one last thing to fix

go edit page on your Google search page and go Modfy sheard webpart on the Search box
Hide the search dropdown and under Mics change the results page to your new Google Search Results and change the Scope (txt box just below) to Google Search Group.
repeat these steps on your Google Search Resluts page

sorry i was in a hurry with this post :P

Monday, 18 June 2007

Adding a document to a Document library

Here is one that stumped me for a while

One of my fellow developers had a web part that needed to convert a xml file to a pdf and then add the pdf to a document library . Well the conversion worked and everything was fine except he couldn’t workout how to get the pdf in to a document library.
There are no overrides on the .Add() method of the SPListItemCollection Class that take File in to account, the .File propriety is only a get and we didn’t know what Field to use. Evan the SPDocumentLibrary class was of no use.

After a bit of head scratching we found that we needed to use the list.Rootfolder.Files.add

This is in the SDK on one line in one of the related classes but I can’t find it again

Hopefully this post will help anyone else that gets snagged on this simple process

A useful tip

The Add method of the SPFilecolection returned a SPFile object
So you can use this code to add your relevant meta data

SPFile newFile = list.Rootfolder.Files.add( fileURL, fileStream);
SPListItem fileItem = newFile.Item;

Hope that help

Tuesday, 12 June 2007

Noooo SharePoint Blogs is down

SharePoint Blogs is down...
One of the best resorces bor a bumbling MOSS newbee developers like my self
But there is light at the end of the tunnel as it is all is not lost
Thanks to Andrew Connell posting info on the problem
SharePointBlogs.com public service announcement

Heres to hoping you will be back up and running soon

Monday, 11 June 2007

Stsadm export / import comand Errors to catch us

Migrating a sub site from one location to another within a single Site Collection.

After a short search you will find that most places point you towards Stsadm.exe -export / import and most of these tuts and How to’s are complete so no need to Blog it again (besides I could not do half as good a job) But what I want to highlight is errors that I have come across when using the commands that I can’t find answers to

Firstly the size of the sub site
When using stsadm.exe export the exported data is not written to destination disk till after the export is complete so if the sub site is larger than the free space on the system disk the export will fail.
Not much can be done around this one you can try reduce the amount of information exported by using the –versions command or create your own migration tool using the API’s
If you know any good way around this please add a comment.

Next Lists with e-mail address
If a list has an attached incoming email address and the Portal incoming email settings Directory Management Service is set to yes. The import fails as it can’t create the email address as it all ready exists short of removing all e-mail support from these lists and redoing the export and import then add email association to the newly imported lists
Best way I have found is to drop all list email association and then do the export and import then add the associations to the new lists.
If you know any good way around this please add a comment.

Lets start exposing my lack of anything

Well i read somewere that app developers should have a blog (evan if they have nothing usefull to say) so here are my ramblings.
This blog is about MOSS 2007. I have only started on MOSS and have a measly 1 month of it behind me.