Showing posts with label MOSS 2007. Show all posts
Showing posts with label MOSS 2007. Show all posts

Friday, March 18, 2011

How to Add Custom Columns to the Search Results in MOSS 2007

A few years ago I demonstrated at the New Zealand Conference how to add custom metadata columns to your search results. What I never did was make a blog post about it. So let me rectify that error of mine.

To get custom columns to appear on your search results page in MOSS you will need to do a few things. First make sure the metadata field is indexed and available by adding it to the Mapped Metadata Columns in the Search Administration of your SSP. Then, recrawl your index. And finally show the new column on the search results page by tweaking some xml and xsl.

1) Get the column indexed and mapped
To do this, open up your SSP admin site either directly or via Central Admin. Then navigate to the Search Administration Page and look for Managed Columns on the left menu. There you will need to add a new managed colum which mapps your custom field. This field could be in a SQL Store indexed via BCS or in a custom list or in a custom content type. In any case I assume that you have already crawled all the content in question, otherwise this step won't work.
2) Recrawl the index
Once you have added the managed metadata colum you need to do a full crawl. Sorry, no incremental crawls will work, as only in a full crawl does the engine do the mapping of all existing fields in the index.
3) Customise the Search Results
Browse to the search results page in your Search Centre. Fastest way? Type in a search into any search box! If you farm is configured correctly that should catapult you to the correct page.
There you need to edit the page and customise the Core Search Results WebPart.

Before you edit the actual XSL Look and feel you need to tell the webpart about the new column. So first click the three dots next to "Selected Columns". You find this option under the ResultsQuery Option. (refer to above screenshot) Copy the text out of the editor into notepad. You'll get this:
Well, you won't get that exactly. It will all be on one line and illegible. Feel free to use an xml editor of your choice instead of notepad.
In that xml you now need to add the Mapped Metadata column name. Make sure you use the correct case. XML is case sensitive! Also add the name you gave the mapped column and not the source metadata column (in case these two have different names). Once you have added the column to the xml text copy it back into the popup for the "Select Columns: option.

(note the new MyCustomColumn entry at the bottom)
Once you have added the xml for the new column you can add the column to the output in the XSLT.
Click the XSL Editor button on the WebPart customisation interface (see first screenshot) and add the new field to your xsl.

Extract before you add the markup:
And now with the new data appearing right next to the description of the search result:


That's it. Copy the changed xsl back into the XSL editor popup, apply your changes to the web part and test your results by executing a fresh search which includes some of the custom metadata that you have indexed.
The next step would be to create a custom scope for your BCD indexed data, create a custom search page and search results page for that scope and go ape-shit on the search results page with loads of custom columns and custom look and feel.
Happy Customising folks!

Tuesday, January 19, 2010

SendEmailNotification not sending emails

This is a tough one. There could be a whole bunch of reasons why your workflow tasks are not sending the OOB emails when a task is assigned. Here are just a few symptoms and their solutions

1) No emails are being sent, not receiving alerts
-Check your SMTP settings in Central Administration. Under Operations you will find Outgoing Email Settings. Make sure that a valid SMTP server is entered there. Either your local machine is running the smtp service which means the local machine name should be there or you are using an external smtp server to send your emails

-Try to connect to the smtp server using telnet on port 25.
a) open up a command prompt
b) type in: telnet smtp.yourserver.com 25
c) If you can connect, type in EHLO or HELO. If any of those give you back useful message your SharePoint Server is able to communicate with your smtp server.
Try sending a test message via telnet:
EHLO
MAIL FROM:someemail@domain.com
RCPT TO:validemail@domain.com
DATA email body
Test email message
.

Done. Make sure to do the CRLF.CRLF bit to send of the message. If it arrives, then you can rest assured that no smtp server config or firewall is blocking your SharePoint server.

Still no emails?
Make sure that the Windows SharePoint Timer Service is set to automatic and is currently in a running state. If that service crashed, or if someone stops it, no jobs will run, including the task emails and alerts.

Still plum out of luck? (been flying too much Air New Zealand lately) Make sure that the user has an email address defined!!! This sounds simple but can be a bitch when using MOSS.
When using WSS, simply click the header where it says Welcome Dude and select Edit my Settings from the dropdown. Add the missing email.
If using MOSS, you will need to update your profile either using your MySite, but if that is not available, go to the SSP Admin site and edit the profile manually there. But beware! Those changes might take some time to trickle down to your different site collections. To speed up the process open a command on the server and type stsadm -o sync
That will kick start the profile sync bewteen the profile store in SSP and the UserInfo Lists in the different SharePoint Sites.

Problem: You still can not see your changes on the userdisp.aspx pages of your site collections. even after executing the sync command and waiting a few moments paitently.
Reason: the user you are looking at is in the system, but not set as active in SharePoint. The only way to activate a user in SP is for that user to log in and do stuff. like adding, editing or deleting list items or documents. So do some stuff and execute the sync command again. That should do the trick.


So now you can see the email address on the user profile page (userdisp.aspx) but still not receiving task emails for your custom workflow tasks...
Maybe you're just impatient. the timer job is set to run every 5 minutes. to speed this up you can change the frequency using stsadm -o setproperty
the property you're looking for is job-immediate-alerts
the value is "Every 1 minute between 0 and 59"
But set that property at your own risk. It will also affect alerts on the farm.



EMail is set, user is active, smtp is behaving and the Timer Service is running, but no emails from your custom workflow.

Solution: First test if you get emails for any OOB workflows like approval and Feedback. If so, then there is an issue with multiple applicaitons using the same task list. I found assigning a new Task list for my custom workflow resolved this issue and SharePoint would send out mails for new tasks as expected. This behaviour is often caused when sites are exported and imported using stsadm. Not all settings are correctly migrated causing this behaviour to crop up. Another reason to be wary of using the export and import functionality in SharePoint to migrate solutions...

Tuesday, October 6, 2009

Multiple Templates per Document Library

I recently got a typical FAQ in my inbox:
"I have set up a sharepoint document library which has a template associated with it, whereby when you create a new document by selecting "new" from the menu bar, the document opens using the associated template.
What I would like to know is, is it possible to associate multiple templates to a document library so that when creating a new document by selection "new", you are offered a choice of templates to use? I'm hoping this is possible!!!"

Nothing simpler than that. The magic word is called Content Types. Okay. Two words then.
You can associate one template with a document library and associate one template with a content type(CT). As soon as a document library(DL) has more than one content type associated with it you will get more than one option when hitting the little arrow next to the new button. Careful, hitting the "New" on the New button will always start up the default CT, which is the first in the list.
So what to do next? Go to the site where you want to use multiple templates and under Site Settings go to the Content Type Gallery. There you create a new CT based of the existing CT called "Document". Now under Advanced Settings of that CT you can upload a new template to use when the New action is chosen. Finally go to Settings page of the DL in quesiton and enable multiple CTs under Advanced Settings of that DL. That will bring up a new section on the Settings page called... "Content Types" where there is a link to add from existing CTs. using that link add your new CT to the list and you're done. You can add as many as you like, but beware, the list should not get too long or you will get usability problems.
One last tip. You can create new CTs at the root of your site collection or within an individual site. CTs are visible only to the site you created it in and all its sub sites. So creating it at the root makes it visible across the whole site collection, but creating it in a specific site will make sure it does not appear further up in the hierarchy or in any of the sibling sites. This can be handy when certain CTs only make sense for specific DLs or specific sites. It is a good idea though to sit down and have a good think about where these CTs could be used and plan ahead where to create them.

Monday, September 28, 2009

Busted! Importing Profiles from multiple organisational units in Active Directory

One big drawback of the way AD implements LDAP is the lack of support for querying on Organisaitonal Units. No matter what you try, you will hit a brick wall when trying something like OU=SharePoint or OU:SharePoint in a simple query. Even trying to access the value as a property of an AD object will fail as OUs are not stored as properties on objects but only form part of the hierarchy and not part of the metadata. So, when importing profiles into SharePoint, the only place where you can enter an OU is when you are selecting the datasource, before applying any filters. Which means only one single OU, right? Wrong. read the solution at SharePoint Mythbuster.com

Thursday, September 24, 2009

Busted: Customising the application.master

There are numerous articles out there about how to change the system master page. The one that all pages in the _layouts aka LAYOUTS folder use. In most cases they want to do this to enable a different datasource for the top navigation aka global navigation. The average rookie who is in charge of creating a site in MOSS using the publishing feature will stumble across this problem and start hacking away at either the original application.master, or even go and implement a custom http handler to exchange the application.master with a custom one on the fly. None of these approaches are best practice nor are they supported by MS. So is it impossible to fix without breaking the system? Not at all.
I've published a solution to www.sharepointmythbuster.com! It will allow you to replace the top navigation on the fly for all pages in the site collection, including those horrid system pages and application pages.

Wednesday, September 16, 2009

Gettting Started with SharePoint development

Microsoft put together ten labs for Developing on SharePoint and also provided a fully functional VPC for you to get started. Time for the image is running out, as it will expire on 30/09/09. So if you don't have your own SharePoint development environment and wish to have a look at what all the hype is about go and download the image quick

VPC Image:
http://www.microsoft.com/downloads/details.aspx?FamilyID=1beeac6f-2ea1-4769-9948-74a74bd604fa&DisplayLang=en

WSS Hands on Labs:
http://www.microsoft.com/downloads/details.aspx?familyid=B885DCE8-C93F-48AA-B798-4422FEBCC200&displaylang=en

Loads of Resources, Demos, and online Walkthroughs
http://www.microsoft.com/click/SharePointDeveloper/

Thursday, September 10, 2009

SharePoint Event Troubleshooting Tips

Gary from Combined-Knowledge pointed out this useful post in the WSS SDK today.
http://msdn.microsoft.com/en-us/library/aa979520.aspx
It is a great little list of issues you will come across when working with Event Receivers in SharePoint. You're bound to have come across the one or other weird behaviour when implementing events. You're not alone. The above list mentions a dozen common issues to be careful of.

How to Pre populate Form Fields in SharePoint

Can't do it better than the boys over at Endusersharepoint. A great JQuery script which works universally with all kinds of Field types including lookups and date time fields.
Just plonk this onto your EditForm or the page with your Dataview and off you go.
Sadly there are no delegate controls on the built in EditForm.aspx for you to override automatically so you will have to either customise the editforms or build your own for your cusotm content type or cusotm lists definition.

http://www.endusersharepoint.com/2009/04/20/jquery-for-everyone-pre-populate-form-fields/

Wednesday, August 19, 2009

Browse button on Send To Other Location in SharePoint

Wilson has put together some time ago now a great little article on how to add the object picker aka a browse button to the "Send To" page in SharePoint. this has been an asked for feature by many customers and the solution is not that hard. it includes creating a custom copy.aspx, a custom core.js and a custom site definition.
http://planetwilson.blogspot.com/2007/08/how-to-add-picker-to-send-to-other.html

You could also create a feature which adds the custom copy.aspx page to the ECB context menu of an item, but you would end up with two send to options in the context menu.

I prefer the feature approach as it is more resillient to change and service packs. Modifying the core.js means you need to check for changes after each update to make sure that the old core.js syntax still works with the new updated version of sharepoint.

Wednesday, August 12, 2009

Showing multiple Content Types in the Content Query WebPart

A common myth is that it is not possible to show multiple different types of content in one CQWP. The trick is that it can not be done using the web interface but can be achieved either via SharePoint Designer or by editing the source xml of the web part directly. The trick is not to think content types but list/library types. you can create a custom search query which will look in multiple different lists by the list type id and pull out the items. as long as the content types you are aggregating are related in a parent/child relationship they will be pulled together. Thus you can create a content query webpart which shows both web pages and documents in one list.

Effectively you need to add two attributes to the CQWP
ContentTypeBeginsWithId="0x0101"
and
ListsOverride="<Lists BaseType='1'></Lists>"

The ListsOverride is the important bit. Here I'm specifying any list which is a document library, as web pages live in document libraries it works like a charm.

Tuesday, June 9, 2009

SQL Server Autogrowth for SharePoint

I was aksed today what Autogrowth setting would be best for a SharePoint Content Database. The simple answer? None! Autogrowth is one of the biggest resource eaters on badly designed SharePoint SQL Farms and can cause serious performance and stability issues (plus wreck havoc with your Hard Disks). The best option is to start big enough for your initial load and plan growth ahead.

Example: You are starting a new SharePoint ECM project and are planning on migrating 5 GB worth of files into the SharePoint Sites at go live. You also realise that you have never used versioning before and your staff will be quite active on about 10% of those files. Expecting to create on average one new version every week. i.e 500MB worth of new data being added every week. Thus scheduling a db file growth of 500MB during every weekend would deal with versioning. Add 100MB for new content to total it up to 600MB for week 1, 610 for week 2, 620 for week 3 and so forth, taking into account the growth of the files and the increase on versioning.

Having a sound versioning strategy with a cap for Major and Minor versions will help reign in this excessive growth!!!!

Obviously you will not always get it right and thus a combination of large Autogrowth (for example in 100MB increments) and weekly scheduled growth will give you the best combination for maximum performance and stability.

The final statement? Try to minimise the amount of times the dbs autogrow as much as you can by planning ahead, and when they do auto grow mak sure the increments are large enough to keep you going withminimal disruption until the next scheduled growth. Don't make them too large either as fetching hard disk space for the db files can put a strain on the Disks at the most impractical times like during peak hours and impair the stability of the system

Wednesday, June 3, 2009

Basic Publishing Site Definition

Andrew Connell wrote in his great SharePoint 2007 WCM book how to create a Minimal Site Definition to use for Publishing Sites. The idea is to have a clean starting point for new Projects which use Features as the main tool for customisation. The Site Definition itself is pretty basic and stripped down to its bare necessities while all the fun stuff lives in Features. A great way to start a project is to plan ahead what functionality will be living in different features, adding basic shell like features to the definition at the start and actually do the coding later. But even if you didn't plan for everything in advance and realise that there is a feature missing or a piece of code that can't be integrated into an existing feature, simple staple it on top of the Site Definition in hind sight and you're as good as gold.
Wrox Press also give you the code for that Book for download on their website. The Solution for the Minimal Site Definition you'll be lookng for lives in Chapter 5. But beware, there are a few bugs in the download. Check the Errata for Errors in Download and fix up the onet.xml and publishing layout page.
One thing that was missed totallly in this definition is the fact that all pages should live in the Pages Library. Also the homepage. In the example from Andrew, the home page lives WSS style in the Root. Not very clean. The fix is simple enough though: Change the url of the page (preferably even changing the default.aspx to actually use the layout properly!) and you're ready to go. Here is my version of the last entry in the onet.xml file:


OLD:
<Modules>
<Module Name="Default" Url="" Path="">
<File Url="default.aspx" NavBarHome="True" Type="Ghostable" />
</Module>
</Modules>

NEW:

<Modules>
<Module Name="Default" Url="$Resources:cmscore,List_Pages_UrlName;" Path="">
<File Url="Default.aspx" Type="GhostableInLibrary">
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/PSATOC.aspx, ~SiteCollection/_catalogs/masterpage/PSATOC.aspx" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_welcomepage_name;" />
</File>
</Module>
</Modules>

Tuesday, May 26, 2009

SharePoint Explorer View in Windows 2008 and 2003

If anybody out there has been building demo machines on Windows Server 2008 or Windows Server 2003 you will have run into this issue at some point. Explorer View does not work on document libraries, nor can you map a network drive to a sharepoint site.
Following constellations come together:

a) the server platforms effectively don't like web folder views until you install the fix KB907306
That fix works for both Windows 2003 and 2008.
Now you can happily map a sharepoint site to your network places and use the Windows Explorer to browse the sharepoint sites.

b) your browser now complains that "This folder cannot be opened in Internet Explorer". This will happen when you have IE 7 or higher and protected mode is on. Simple. Disable protected mode via Tools>Internet Options>Security. Remember to add the site to the Intranet Zone

c) What? can't disable the protected mode on Windows Server 2008? No problem. Open the Server Manager. On the root node of the tool you should see Server Summary within there is a section for Security Information. Here you will find a link to Configure IE ESC (Enhanced Security Configuration). That's where you can disable the "microsoft parental controls for dummies" tick box.
d) now you can disable protected mode on the Intranet Zone.

You might ask, why not simply move the site to Trusted Sites. Well, Trusted sites actually have a higher security rating than Intranet zone. Plus you automatically get signed into the intranet zone and not to th trusted sites. Plus the sharepoint site is on the Intranet. So that is also the Zone it should live under!

PS. Running Windows Server 2008R2 or Windows Server 2008 SP1? Then try enabling the Feature called  "Desktop Experience" in the Roles and Features configuration of the Server

Happy Exploring!

Tuesday, March 31, 2009

SharePoint training from the best

Steve Smith and Ben Curry are coming to the SharePoint Conference and will be holding a five day hard core SharePoint Workshop. This is not for the faint hearted! Learn from the best in an interactive and engaging session where it is all about hands on and hats off.

When? The week after the conference 06/07 until 11/07
How? send a mail to chan@knowledgecue.co.nz to express your interest
Where? TBA

Course outline and registration will be online soon. Watch this space!

Friday, February 20, 2009

Content and Structure Reports: All Checked out documents

Ever wanted to see all documents that are checked out right now and deal with them all in one go? Not only the ones checked out to you? here is the CAML syntax for your Content and Structure Reports Library located at the root of your publishing enabled SiteCollection:

<Where><Geq><FieldRef Name="CheckoutUser" LookupId="TRUE"/><Value Type="int">0</Value></Geq></Where>

Simply create a new Item in that list with the above text for the CAML syntax, give it a Title and meaningful description and you're set!

Content and Structure Reports: Stale documents

Ever wanted to find out where your unused documents lie in MOSS?
This is the syntax to find all documents that have not been modified in the last year. The field to check against is the Last Modified Date. Best is to use it's ID.

<Where><Leq><FieldRef ID="{173f76c8-aebd-446a-9bc9-769a2bd2c18f}"/><Value Type="DateTime" IncludeTimeValue="TRUE"><Today OffsetDays="-365"/></Value></Leq></Where>

Remember not to have any whitespace in between the tags, especially no CRLF.

The trick here is not to use [Today] but instead also use the OffsetDays to go back and forward in time and if you want to make sure that the time is matched, include the IncludeTimeValue="TRUE" attribute. This attribute comes in handy in many cases when you want to check against "Now".

Friday, November 28, 2008

Changing the AssetPortalBrowser Behaviour

Following are some instructions on how to change the default behaviour of the AssetPickerDialog also known as AssetPortalBrowser.aspx

1) Change the paging size: That's an easy one!
go to the ProgramFiles\....\12\Template\LAYOUTS folder and edit AssetPortalBrowser.aspx. BEWARE. Do not edit with SharePoint Designer. It will change all the paths and nothing works no more.
On that page you will find a control called ObjectList1 of Type SMObjectList. It has a PageSize attribute wich you can change from 15 to anything you like really.

2)Changing the Default Sort behaviour: Tricky!
Sadly enough setting the SortDirection ad SortExpression on the Control will not come into effect as the sort is overridden every time the context changes. And the context changes every time the page is loaded. Thus, no matter what you set here it does not seem to work.
The Workaround includes some C# and visual Studio knowhow.
a) Create a new Class Library
b) Add References to the the Microsoft.SharePoint, Microsoft.SharePoint.Publishing and System.Web dlls
c) Create a new Class that inherits from Microsoft.SharePoint.Publishing.Internal.CodeBehind.AssetPickerDialog
d) override the OnLoad event and set the SortDirection, SortExpression and ExplicitView of the ObjectList1 Control programatically. Do this after calling the base.OnLoad() event to make sure the control is loaded correctly.



public class CustomAssetPicker: Microsoft.SharePoint.Publishing.Internal.CodeBehind.AssetPickerDialog
{ protected override void OnLoad(EventArgs e){
base.OnLoad(e);
this.ObjectList1.SortDirection = "DESC";
this.ObjectList1.SortExpression = "Modified";
this.ObjectList1.CancelSortOperation = false;
this.ObjectList1.ExplicitViewName = "All Documents";
}
}





e) sign the assembly

f)install the assembly into the GAC either using gacutil or drag&drop it into c:\windows\assembly
g)fix up the web.config to allow the new assembly by I)adding it to the SafeControls list and II)the compilation\assemblies list
h)Change the Page directive on AssetPortalBrowser.aspx to inherit from your new class instead of the Codebehind class.

Voailla, you now changed the default sort to always show the last modified files and images first.

Thursday, November 13, 2008

Data Views and the AdventureWorks Database

If you ever tried to get Data Views to work with the AdventureWorks DB you probably have had as much pain and frustration as I have had in the past.
First you'll need to get SSO set up to connect to the DB. That's simple once you know how!
Then you select the table you want and when you try to show the data you keep on getting error messages! The problem here lies in the fact that AdventureWorks uses Schemas everywhere. And you need to fully qualify your tables to be able to access them. SarePoint Designer is not clever enough and forgets to put the schema name infront of the select command.

Here are two possible solutions:
  1. simply write the select statement yourself instead of picking the table from the list. A simple statement like Select * From Production.Product will get you going in no time.
  2. Create a deidacted login for a specific schema and define the defauls schema.

Here are the steps for the latter option:

  1. Create a login on the SQL Server called AWProduction.
  2. Set its default database to AdventureWorks.
  3. In its user mappings give it pubilc access to AdventureWorks and specify the Default Schema to be Production.
  4. go to the schema definition on the AW database and give AWProduciton all the required permissions on the Production Schema.
  5. Set up a new SSO Application that uses the new AWProduction Login
  6. Use that SSO login for your Data Connection

Hope that helps!

Using Dataviews to edit and update SQL data

If you hooked up your dataviews with SQL data and enable editing you most probably have come across following error message:
The data source control failed to execute the update command

The reason for this can be manyfold, either you might have a data type issue where you have non numerical data being pushed into a numerical field or in my case as simple as a database constraint getting in your way.
Dealing with the select, update, insert and delete commands manually can be a bit of a pain. So I really like the ability to pick my table and let SharePoint Designer worry about the rest. Just a shame that SharePoint designer does not understand one simple rule. You can not update a column which is the identity column of a table. SQL server reserves the right to auto increment that column. How to fix it? two ways:

The simple way:
Start with a blank Data View and make sure not to add the ID column to the list.

What if you want to show the id though?
The hard way:
same as above but you then you add the ID not by using the Edit Columns... task but simply by adding a new column to the dataview itself (click into first column of the DataView, right click and choose Insert...Column to the left) and injecting the ID manually. Easiset way to do that is to copy one of the other fields and then changing its databinding to point to the ID field.

Thursday, July 17, 2008

Major SharePoint Updates Released

Some major updates were released a couple of days ago fixing many issues with content deployment and performance, as well as including new features in the search and adminstration area. Definately worth checking out!
http://blogs.msdn.com/sharepoint/archive/2008/07/15/announcing-availability-of-infrastructure-updates.aspx