Sunday, May 27, 2007

SharePoint Designer Deployment Issues

Hi All,

Many of you may already noticed (the rest are in for a big surprise) that when creating team sites while using SharePoint Designer there are several issues that prevent saving the site as a template and creating sites from it.

When you are using a Data View Web Part (DVWP) or the Workflow Designer, your sites created from the template will show a generic error and will ask you to open and fix the problem using SharePoint Designer.

For example, if you are adding a list view web part and right click->convert it to xslt data view web part it will work fine. But if you used the "Data view" menu at the top -> insert data view and then connected it to a list/library - your DVWP will throw this error when saving it as a site template.

After much searches for a solution the WCM dev team came up with a solution that explained the reason for this problem.

Apparently when you are creating any list references (for example: lookup field, dvwp on a list, workflow etc) all list references are represented as the list's GUID.

When saving a site as a template the GUID is marked for replacement on all new sites created from this template. After creating a new site from that template all marked GUIDs are replaced with the new GUIDs of the new lists on the new site.

So - where is the problem? Apparently in very few cases the list GUID is stored as ListID=GUID, and not as it should be - ListID= {GUID}. When the GUID is not wrapped in {} the SharePoint replace mechanism does not recognize the list id and does not mark it for replace...

The fix for this is rather easy, after adding a WF or a DVWP all you have to do is to dive in the ASPX or XML and wrap all GUIDs with {}...

Believe it or not - this actually saves the day and things are starting to work!!!

There are talks of fixing it in service pack (SharePoint or Designer? don't know...) but for now this is the only way I know of.

Hope this helps you guys; it sure did take a lot of my time finding this solution so I'd thought I'd share...

Saturday, May 26, 2007

If you cannot compile an audience and get no error

Description:
Recently I was at a customer site where we were implementing a MOSS based solution. while moving to the production - after a backup and restore process we tried to create several audiences and when we tried compiling them they did not compile successfully but we got no indication for an error.

After a quick view at the server's event viewer – we found some SharePoint error message like: 'Failed to compile 'my audience' audience. Exception was: 'Failed to obtain crawl status.'

A quick search reveled that during the restore process our SSP (SharedServicesProvider for MOSS) did not have a search indexer defined.

In order to fix this problem what we had to do is:
1. make sure the office SharePoint services search service is active on our farm (in central administration->operations->services on server)
2. Go to central administration->application->configure the SSP we are using and select search indexer server from the drop down list (after step 1 this options should not be empty)
3. Done.

Now the compilation could be completed!

Hope this helps you guys,

Shai Ben Shooshan
SharePoint TechnologySpecialist
KWizCom Knowledge Worker Components
shai@kwizcom.com
http://www.kwizcom.com

Thursday, May 17, 2007

Creating an advanced search on a list

If you ever wanted to have an advanced property search on a SharePoint list – your worries are now over.

Almost all SharePoint lists views supports having a filter-combo box above them. Only you have to show the toolbarin order to use it and it hides the filter boxes by default.

here is a little javascript code snippet that will force the list web part always show the filter combo boxes and thus providing property-based search on your list.

All you have to do is add a content editor web part to your page and add this javascript to its source editor:



<script>
function NewSubmitFormPost(url)
{
if( url.indexOf("?") > 0 )
url += "&";
else
url += "?";
url += "Filter=1";
OrgSubmitFormPost(url);
}

var OrgSubmitFormPost = SubmitFormPost;
SubmitFormPost = NewSubmitFormPost;

if( window.location.href.indexOf("Filter=1") < 1 )
window.location.href = window.location.href + "?Filter=1";

</script>



This little code bit sure saved me some long development hours...
:)

Monday, May 7, 2007

Using FrontPage Data View Web Part Without Un-Ghosting the Page

Introduction to FrontPage data view web part:




This article will demonstrate how users can make use of the powerful data view XSL Based web part without having to pay the cost of un-ghosting the page like using FrontPage normally do.
This web part has many exiting features and can save hundreds of development hours by creating a data view web part that can connect to various data sources such as:
· Web Services
· Databases
· Excel Files
· XML Files
· SharePoint Lists
Plus it offers a great deal of formatting feature like:
· Filter
· Conditional Formatting
· Sorting
· Field Format (display as link Etc.)
Now, as if this was not enough – this cool web part also exposes a provider and consumer web part connections to enable us creating an interactive solution.

Why am I telling you this?




Well, being an experienced SharePoint solution provider or a newbie you must know all about this feature provided by FrontPage.
Also – you must of heard the warning about using FrontPage on your SharePoint site pages – you don’t want to regret un-ghosting the files from the template, do you? – well, in most cases you cannot afford this price.
For more information about ghosting or un-ghosting pages please see this blog for example.
Well, there is a secrete way you can utilize this powerful tool (FrontPage) to construct the data view web parts you want and use them in your page with no need to un-ghost the page. Sound exiting? Tricky? You will be amazed to learn how easy it is!

Solution Description




Quick Overview


For those of you who are experienced with using both SharePoint and FrontPage, here I will lay down the principal of the solution. You may find it inspiring for more other solutions based on the same concept like I did.
What we want to do in order to achieve our goal is to create a playground.aspx page on our site. Then we will use FrontPage to add edit and change the data view web parts and save the page.
So far – normal FrontPage unwanted work. But not to worry – here comes the big change:
After we have finished creating the web parts, connecting them and customizing the XSL code if needed we will browse to our playground.aspx page using the internet explorer and export these web parts to a DWP file.
All we have to do now is browse to our default.aspx page, import these web parts and what do you know – we have them up and running with no un ghosting taking place.
Tip: you can use the Data Transformation Services to create views to remote lists as well.
The playground.aspx file can now be deleted.

Our Solution Step-By-Step


1. Open FrontPage
2. Nimrod – Please add steps to adding a data view web part
3. Save the page and close FrontPage
4. Open the page you created in the browser
5. Look for the Web Part you added using FrontPage earlier
6. In the web part menu you’ll find the “Export” option – click it
7. This will download a “.DWF” file to your local PC, save it with the web part name
8. Browse back to the original page you wanted to add the Web Part to, Click Add Web Parts
9. Select “Import option
10. Click Browse and select the “.DWF” file you saved earlier
11. Click upload
12. The Web Part will be loaded to the tool pane, drag and drop it anywhere on the page to use it
13. Done!!!

Summary




Hope you find this useful and finally we will start making use this great tool – FrontPage. These guys did a great job and we can benefit very much from the tools available there.
And guys – feel free to contact me if you have any questions or if there were something obscure in here…

Enjoy,

Shai Ben Shooshan

Adding a new content query report

Many of my customers are experiencing problems during the creation process of their publishing portals in MOSS 2007 WCM enabled sites.
The two main issues I found are not having an easy way to check-in and publish/approve all pages we developed at once (very much needed when building a new site) and the ability to view all checked out documents in my site collection – just so we could know where we stand in our publishing process.
For the first problem I had to write a nice utility (I will try to publish it for free soon… promise! When finished it will be available here: http://www.kwizcom.com/ – look for the free stuff), but for the second issue I found a simple solution that asked for no more than few seconds of "hard labor" to solve.
(by that I mean some googling was needed)
Well, you might of noticed content editing enabled sites have some reports in their site settings menu:



Clicking one of these menu items will bring you to the manage content and structure page, where a search will be performed on all items according to the report you wanted.



Now, adding a new report to this list turned out to be really easy. All I had to do is click the "content and structure reports" list under the root site and there I found all queries there with their CAML code!


So – to add a new search that will show all items that are checked out to any user simply add a new item there and set this as the CAML for the item:
<where><isnotnull><fieldref lookupid="TRUE" name="CheckoutUser"></isnotnull></where>
Now, this is not perfect yet, you could limit this query to lists/libraries etc… but hey – I have to leave something for you guys to write about, no?
Hope this helps some of you guys, don’t forget to vote!







Shai Ben Shooshan
shai@kwizcom.com
KWizCom Canada

Sunday, May 6, 2007

Adding the quick launch to team site pages

Hi All


Ever tried to add a new page in a WSS Team Site?

Well, after you create a new page, using the "Create web part page" wizard:





you probably noticed the following issues:

1. You have to create a document library to store them (unless you save them in "Shared Documents" library, but we wouldn't want to mix documents and site pages, would we?)

2. They look different from the team site's home page - where did the quick launch go??







OK, so the solution is quite simple, and there are 2 cases here:


1. If you have MOSS 2007 - All you have to do is to activate the "Office SharePoint Server Publishing" feature for your team site. Once you activate this feature, the team site will have some publising site features: a new "pages" library will be created, and all new created pages will be automatically stored in this library. In addition all pages will display the same "envelope" - including the missing quick launch on the left side of each page.

The only problem with this solution is that now every change you make requires publishing, and this is certainly NOT a natural part of team-site working flow.


2. If you only have WSS installed - in this case you don't have the "Office SharePoint Server Publishing" feature installed. however, you can change the team site page templates, and have them display the quick launch. This is quite easy to implement, so here it goes:
  • Browse the "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\STS\DOCTEMP\SMARTPGS" folder on the SharePoint server.
    This folder contains all templates that you see in the "New Web Part Page" wizard:



  • Every page inherits the same team site's master page, and all of them override this master page's placeholder tags. This is why the quick launch is not displayed in new pages created in a team site (don't ask me why it was done like this, I don't have a clue..).


  • Simply delete the "PlaceHolderLeftNavBar" content tag in the required templates and save the file/s:


That's it!


Now, create a new web part page, based on the template you have just changed, and notice that the quick launch appears exactly as it is in the home page.

One last thing to remember:

Since the changes are done in the file system, these changes apply to all team sites on your SharePoint server.



Nimrod Geva
KWizCom - Knowledge Worker Components











Friday, May 4, 2007

UTF-8 with signature?

Few days ago I was at my customer and we witnessed a wired behavior of excel.

We wanted to display data in excel from the web, so that when you click a link excel will open and display some data in it (not within explorer).

Doing this is pretty simple, all we have to do is create a data grid control, bind it to a data source and let it render.

When we want it to open to excel we have to replace the "pre-render" method with this simple code:
Page.Response.Clear();//clear other HTML form response
Page.Response.AddHeader("Content-Disposition", "attachment;filename=StudentsList.xls");//to open in excel
Page.Response.Charset = "65001";//for UTF-8
myDG.RenderControl(writer);//render grid HTML
Page.Response.End();//End response here.

This works great for most cases.

My client had to display some non-English characters that were all UTF8 encoded. When saving the result HMTL in notepad using UTF8 excel was able to display the special chars ok, but when using the code sample above - we got some wrong data.

After googling around for a while i managed to understand that excel must use UTF8 with signature text and i had to add a signature to it.

So - how do I signature my file as UTF8???

Some more googling allowed me to learn that all I needed to do is add these bytes to the start of the file:
0xEF, 0xBB, 0xBF

Using C#, here is the complete and correct way to do this:

Page.Response.Clear();
Page.Response.ContentType = "application/vnd.ms-excel";
Page.Response.AddHeader("Content-Disposition", "attachment;filename=StudentsList.xls");
Page.Response.Charset = "65001";
byte[] b = new byte[] { 0xEF, 0xBB, 0xBF };
Page.Response.BinaryWrite(b);
myDG.RenderControl(writer);
Page.Response.End();

Now everything should be rendered okay and my file is saved with UTF8 with signature!!!

Hooray!

Well, hope this helps, since I didn't manage to find any document that explains this I thought it might help if I publish one...

Peace, Shai.

Tuesday, May 1, 2007

Un Documented Navigation Control using C#

Hey All,

I run into a requierment during a site creation automation at one of my customers.
In this automation we had to dynamically add links to the site's navigation only to learn that the sharepoint API for this is not what I expected.

What i needed is to do some simple things (or so i tohught) like adding header items, adding items with no link, specify links to open in new window etc...

well i came across some undocumented things that helped me do these not so simple tasks... I added here some of the code I used so it may help so of you out there.

I wanted to add navigation controls like:
· No link (href) for new navigation item (not as simple as you thing… I wanted it not to behave as a link.)
· Add a link that will open in new window
· Create a container navigation item to hold several child links
All of these are fairly simple to do using the UI, but not so simple when using code to create the links.
I did manage to control each of these features using navNode.Properties
Now, I could not find any documentation regarding how we suppose to do it, so what I had to learn myself is not documented so far anywhere I looked.

Now, with no further ado, here are some source code samples I collected:
Use this to add a container with no link:
navNode = new SPNavigationNode("Container", null, true);
navNode = CourseWeb.Navigation.QuickLaunch.AddAsLast(navNode);
navNode.Properties["UrlFragment"] = "";
navNode.Properties["NodeType"] = "Heading";
navNode.Properties["BlankUrl"] = "True";

Use this to add a link in the container:
SPNavigationNode tmpNavNode1 = new SPNavigationNode(LinkName, LinkUrl, true);
tmpNavNode1 = navNode.Children.AddAsFirst(tmpNavNode1);
tmpNavNode1.Properties["Target"] = "_blank";
SPNavigationNode tmpNavNode2 = new SPNavigationNode("Second link", "link url", true);
tmpNavNode2 = navNode.Children.AddAsLast(tmpNavNode2);
tmpNavNode2.Properties["Target"] = "_blank";//open in new window

navNode.Update();
tmpNavNode1.Update();
tmpNavNode2.Update();
CourseWeb.Update();

Well, I know I spent a lot of time to find how and what to do… could it be that SharePoint team cut few corners in the API?

Anyway, hope this helps some of you developer guys,
Shai Ben Shooshan