Thursday, December 27, 2007

SQL Server error updating WSS/MOSS

Exception: System.Data.SqlClient.SqlException: The configuration option 'min server memory' does not exist, or it may be an advanced option. Ad hoc update to system catalogs is not supported.

I have encountered this error during the step 2 in the wizard. It is due a configuration in the SQL Server 2005 and the solution is to execute the following script:

exec
sp_configure
'show advanced options', 1;

GO

RECONFIGURE
WITH
OVERRIDE;

GO

sp_configure
'allow updates', 0;

GO

RECONFIGURE
WITH
OVERRIDE;

GO

After that the wizard finishes successfully.

Related links:
http://www.webservertalk.com/archive132-2007-4-1871302.html (I found here the script)

Thursday, December 6, 2007

Translatable content deployment using variations

Today I have read about content deployment and the variations while I was looking for a solution to translate the content in a site automatically. After read some blogs and specially this white paper I have reached the conclusion that MOSS does not offer a complete solution.

The existence of the translatable columns can confuse you (I had very expectations about it). This attribute of a site column only indicates whether must be traduced or not. But who has to translate it? The white paper says literally:

"… They (editors) can export the content, provide the exported content to translators, let translators translate the content, and, finally, re-import the translated content onto the sites. During the export process on a variation target site, all pages are exported and packaged; this can add up to a lot of content. A feature called Translatable columns can help translators to identify what needs to be translated. …"

So, there is not any translation process involved in the publishing process. A possible workaround is to create a custom workflow activity that checks for the translatable columns in the item and traduce it using a web service (babelfish or worldlingo for example) and then associate it to the page libraries in the variation sites.

Another important issue of the content deployment using variations is the fact that a little change in a root variation page implies a total deploy of this page in the dependant variations as a draft version. The proposed solution is to add a workflow to delete this draft version using a Boolean field:

"… One way to address this scenario would be to create a custom Boolean column for the Page content type that can be used by the content editors on the variation source site to mark new versions as "corrections" when necessary. Then, you could create a custom workflow and deploy it on only the target sites. This workflow would need to check every change to read the custom column's value: if the value were True, the workflow would simply delete the new version created by the variation process on the target site. If the value were False, the workflow would preserve the new page so content editors could translate it. ..."

This workaround could be complementary to the previous workaround and we would have a "complete" solution to the translatable content deployment using variations.

Please, feel free to add comments in order to get a "better solution".

Related Liks:
http://sjoere.blogspot.com/2007_11_01_archive.html

Thursday, November 22, 2007

SPQuery inside a foreach bucle

Today I have found a strange behavior of the SPQuery class. My code has the following structure:


SPList list = web.Lists["MyList"];
SPQuery query = new SPQuery();
foreach (DataRow row in table.Rows)
{
query.Query = "<Where>Some CAML Query with a row dependant condition</Where>";
SPListItemCollection items = list.GetItems(query);

}

After the first iteration, the SPListItemCollection items always contains the same items, although the Query property of the query has been changed in the bucle. To resolve it I have putted the initialization of the SPQuery inside the bucle:


SPList list = web.Lists["MyList"];
foreach (DataRow row in table.Rows)
{
SPQuery query = new SPQuery();
query.Query = "<Where>Some CAML Query with a row dependant condition</Where>";
SPListItemCollection items = list.GetItems(query);

}

And now all works normally.

Wednesday, November 7, 2007

A button to submit content to SharePointPedia

Try it on my page. With this simple code on your page you can add a button to submit the content to the SharePointPedia:

<input alt="Submit to SharePointPedia.com" name="Button1" type="image" src="http://sharepoint.microsoft.com/Pedia/PublishingImages/SPP/topbar_logo_spd.gif" value="Submit to SharePointPedia.com" onclick="javascript:location.href='http://sharepoint.microsoft.com/pedia/pages/post.aspx?url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title)" />

Enjoy it!

Monday, November 5, 2007

An easy way to change the SharePoint index file’s location

This solution is valid for these scenarios where a full crawl is not a problem. In these cases you can move the index stopping the Office SharePoint Search Service and starting it again. In the form to start it you will find a textbox to indicate the new location of the index file. Then you will need to assign the index server for each SSP and start a full crawl for each content source. Remember that during the processes the search results will be incomplete.

After that I have some questions:

  • How could we change the default index location without reinstalling SharePoint?
  • In the default index location there are some folders with text files. Which is their function? I think they are related with the SQL Search, but I am not sure.

To understand the key concepts of the search infrastructure I have read the chapter 17 (specially the page Choosing a Search Implementation Topology Model) of the Microsoft Office SharePoint Server 2007 Administrator's Companion.

Related links:
https://blogs.pointbridge.com/Blogs/robinson_will/Lists/Posts/Post.aspx?ID=21 (move the index without a full crawl)

Monday, October 15, 2007

SPUtility.HideTaiwan - What does it do?

Thanks to intellisense I have discovered this method. The MSDN documentation about it is empty and I have "googled" it and I have found another related post but without any response.

Anybody knows what would happen if I execute it? SharePoint is scaring me…

Thursday, October 11, 2007

CQWP debug item style

Reading this post a few months ago I found this great tip. If you want to know what are the fields that your CQWP receives you can use this item style to "debug" it.

<xsl:template name="Debug" match="Row[@Style='Debug']" mode="itemstyle">
<xsl:for-each select="@*">
            <br>
                <xsl:value-of select="name()" />
            </br>
        </xsl:for-each>
</xsl:template>

It will show all the fields passed to the web part (internal names). I recommend you to read the entire article; it shows the basis about the customization of the CQWP.

Related links:
http://blogs.msdn.com/ecm/archive/2006/10/25/configuring-and-customizing-the-content-query-web-part.aspx

Tuesday, October 9, 2007

SPQuery returns all items

If you execute an SPQuery through the SPList.GetItems(SPQuery) method and get all the items in the list, check the syntax in the Query property. The U2U CAML Query adds the tag <Query> to the query and it is not necessary in the Query property of SPQuery. For example:

SPList list = new
SPSite("http://MySharePointSite").OpenWeb().Lists[listName];

SPQuery query = new
SPQuery();


query.Query = "<Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">Test</Value></Eq></Where></Query>";
SPListItemCollection items = list.GetItems(query);

This code returns all items in the list, but if you remove the <Query> tag all works fine:

SPList list = new
SPSite("http://MySharePointSite").OpenWeb().Lists[listName];

SPQuery query = new
SPQuery();


query.Query = "<Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">Test</Value></Eq></Where></Query>";
SPListItemCollection items = list.GetItems(query);

Related Links:
http://joeshepherd.spaces.live.com/Blog/cns!9AE2097A4A610B63!123.entry

Friday, October 5, 2007

"Windows cannot find specified device, path or file.You may not have the appropriate permissions to access the item"

I have encountered this error today when I tried to execute a downloaded file on a Windows 2003 server. The cause of the error was the Internet Explorer Enhanced Security Configuration that is installed by default on a Windows 2003 R2. When you have installed it and try to execute a downloaded file it prompts this error.

To disable it:
1. Add or Remove Programs
2. Add/Remove Windows Components
3. Uncheck Internet Explorer Enhanced Security Configuration
4. Next

More info:
http://technet2.microsoft.com/WindowsServer/en/library/910d7a79-fd6f-447e-9bb1-bc9e57d54ec41033.mspx?mfr=true

Thursday, October 4, 2007

Common problems with the MOSS variations

One of the most fantastic features in MOSS is the multilanguage support. It is accomplished through variations and I am going to explain two of the problems that I have encountered with it.

The invisible language selector: When you enable features on a site and create the variations, is probably that you are unable to select the language. The reason is a commented line in the language selector user control. You only have to uncomment it. The user control is located at “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES\VariationsLabelMenu.ascx”.

The variation systems crash, how to trace it?: A negative aspect of the variation system is that it do not alert when it fails. Then, the first place to look for any issue is in the variation logs at the top level site settings. The variation log shows all the activity of the variation system and shows errors like duplicate pages or content type errors. If this log is not useful you can explore the SharePoint logs (in the “hive 12”), but if the logs do not show the problem the next step is to check the state of the scheduled jobs in the farm. There is a job responsible of the propagation and it can be found in the Operation’s section in the Central Administration. If there is a problem with the jobs you can restart them restarting the Windows SharePoint Timer Service (services.msc) in all front-ends. It will restart all the jobs and the variation propagation will begin to work again.

I hope it help you!

Related Links:
http://blog.hametbenoit.info/Lists/Posts/Post.aspx?ID=168

Sunday, September 30, 2007

SharePoint and Integration Services

I am going to explain a simple way to load a SharePoint list with the information stored in a SQL table or other source accessible from SSIS. The objective is to create a mechanism that updates the content of the SharePoint list periodically with the data stored in a table. The solution is obvious but I will expose the different approximations to the solution and the alternative that I implemented.

BDC: My first thought was use the BDC to expose the information through the SharePoint site, but it was too complex (I only wanted to show the info in a table) and this solution was not compatible with WSS.

Object Model: We can create an assembly that updates the content with the SharePoint API. This solution would be acceptable if the SQL Server and the SharePoint server was in the same machine, but this scenario is too simple for a real situation. In addition, it involves deploying the assembly through all the servers in the farm (using a feature) and creating a SPJob to execute it periodically.

SSIS Web Service Task: This would be the ideal solution, but this SSIS task is unable to invoke the SharePoint web services L.

Custom SSIS task: Whether the out-of-the-box task in SSIS is unable to invoke a web service, why we cannot create a custom SSIS task? Well, I prefer to wait until a future version of SSIS that include it J.

SSIS Script task:
This is the solution that I adopted. It consists in the extraction of the information with a common SSIS package and, at the moment of the load of the content to the SP list, a SSIS script task inserts the data in the SharePoint list through the WSS web services. The main problem is how to invoke the web service and for that reason I used the wsdl.exe to create a proxy class which was able to invoke the web service. Then I added this proxy class to the script task and gave the appropriate permission to the list in order to the SQL Agent identity was able to invoke the web service. So, the solution only consists in a SSIS package that an SQL Server job executes periodically.

This is my solution, but I am sure that it is not the best solution to all cases. In my case the information was about 15.000 rows and the load of all content was completed in 30 minutes. In others cases it may be unacceptable and the only acceptable solution would be the BDC.

Related Links:
http://msdn2.microsoft.com/en-us/library/7h3ystb6(vs.80).aspx
http://msdn2.microsoft.com/en-us/library/lists.aspx

Thursday, September 27, 2007

Add a new SPGroup programmatically to SharePoint

Recently I have developed a web application to interact with SharePoint. Its objective was to hide the SharePoint UI to the final users in order to they can administer the site collection without any knowledge of SharePoint. Users have rights to manage users and groups but we wanted that they did not navigate through the administration pages of the site. For that reason the web application uses the API to do all the operations. At the moment the most complex operation has been the "add new group" due his poor documentation. This is the code that I have used to accomplish this operation:

//Add the group to the SPWeb web
web.SiteGroups.Add(groupName, owner, defaultuser, description);

//Associate de group to the SPWeb. Now it will display in the quick launch bar
web.AssociatedGroups.Add(web.SiteGroups[groupName);
web.Update();

//Assignment of the roles.
SPRoleAssignment assignment = new SPRoleAssignment(web.SiteGroups[groupName]); SPRoleDefinition roleApp = web.RoleDefinitions["Aprobar"]; assignment.RoleDefinitionBindings.Add(roleApp);
SPRoleDefinition roleCol = web.RoleDefinitions["Colaborar"]; assignment.RoleDefinitionBindings.Add(roleCol);

Friday, August 10, 2007

Sharepoint and Integration Services

In some cases the best way to import data to our portal is not to use BDC due complexity that it involves. Somebody could think that with SSIS we can insert elements in a SharePoint list OOB, but it is not true. The Web Service Task permits to interact with an external web service but is very limited because are not compatible with all web services. The Lists.asmx web service from SharePoint is not supported and you have to take a workaround to import information to SharePoint.

The solution is trivial: you can generate a proxy class to communicate with your service with de WSDL.exe tool included in the command line tools of VS2005. Then you can add a Script Task to your SSIS project and add to the script a new class with the code that you have generated with WSDL.exe. After the necessaries "add references" you can interact with your WSS or MOSS through its web services.

And to upload document… you can use the UploadData of the WebClient class.

Enjoy it!

Tuesday, July 17, 2007

Starting a SharePoint Timer Job manually

During 2 days we had the SharePoint environment down due a transaction log too large. The root problem was the recycle bin. We threw a process that updated all the files on the site with the unlimited versioning enabled in its Document Libraries. The process executed each 5 minutes and every execution duplicated the info in the site as an old version of each document. After take off-line the database, detach it and attach it again without the transaction log (see the post that explain it) we could recover the space necessary to work. Then we delete each old version of the documents and send it to recycle bin. After set the quarentine period to 1 day we did not want to wait 1 day to get the space free. For that reason, we made this simple code to execute the SPJob that actually deletes the files in the database when it has been deleted of the second level recycle bin.

SPSite site = new
SPSite("http://<URL>");

foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)

{

if (job.Name == "job-recycle-bin-cleanup")

{

    job.Execute(new
Guid("C864BB7F-7346-4538-9720-2AADB2ED5247"));

}

}


 

The guid that ypu have to pass is the guid of the content database. I retrieve right clicking on the content database in the central administration (remember to substitute the hex code of the hyphens '-'). In this example the guid retrieved was: DatabaseId=%7BC864BB7F%2D7346%2D4538%2D9720%2D2AADB2ED5247%7D

Related Links:
http://experienciasnet.blogspot.com/2006/09/shrinking-log-file-in-sql-server-2005.html

Tuesday, July 10, 2007

How to make your own WSP

When I asked myself this question I thought in the VS2005 extensions for SharePoint. I discovered then that it was only supported for an environment with stand alone installation. I could deploy a solution only the first time (it only gives me an error about a feature not installed). The successive times I get an "Object reference not set to an instance of an object" and VS2005 didn't create the WSP file. Then I find the post about the Timer Job in WSS and a link to the method to deploy the solution without de extensions for VS2005. It seems complex, but it isn't.

Note: I had to activate the feature from the command line (stsadm).

Related links:
http://www.andrewconnell.com/blog/articles/UsingVisualStudioAndMsBuildToCreateWssSolutions.aspx
http://www.andrewconnell.com/blog/articles/CreatingCustomSharePointTimerJobs.aspx (An example of WSP)

STSADM “Command Line Error”

Today I was deploying a solution to my server through the command line. After pasting command that I had copied from a web I received the "Command Line Error". The solution is to write the command without paste. The reason is the encoding of the pasted text. I found the explanation in the blog in the related links.

Related Links:
http://blogs.msdn.com/sharepoint/archive/2007/02/24/updated-installation-guide-for-the-20-server-admin-application-templates-for-wss-3-0.aspx



 

Friday, June 29, 2007

70-541 – My first SharePoint certification

Today I have passed the 70-541 exam. It is about development in WSS and it is not difficult if you have the key concepts clear. The questions are 80% about the API (managinitems, lists and sites) and the rest is about deploying the solution.

Friday, June 1, 2007

Accessibility, CSS Friendly Controls, AspNet Menu and IE6

If you are developing an accesible site with ASP.NET 2.0 you can use the CSS Friendly Controls Adapters to render the controls without tables. You can access to the project at http://www.codeplex.com/cssfriendly. The current release of the AspNet Menu does not work with IE6 and the menus are invisible. After some investigation I discover that the problem is the Menu.css in the project. I have excluded this file and it shows the menu in IE6. Finally I have discovered what was happening. There is a bug in IE6 with the next class included in the Menu.css:

ul.AspNet-Menu

{


position: relative;

}

If you delete it all will works fine. For that reason I recommend to check the CSS files included in the project and verify it if you detect some strange behavior. In our case we have model the menu in the css of the application.

Special thanks to Edu and Victor who detect it.

Related Links:

http://www.codeplex.com/cssfriendly


 

Monday, April 16, 2007

You may re-try the operation, and you may need to clean up the half-created data first before re-creating.

I encountered this "fantastic" error when I tried to create a new variation in my site. I did that in many other occasions without problems but today it has failed. The result is that the process makes a partial copy of the root variation. I don't know the reason, but I have encountered the causes. It failed when the variation process tried to copy two pages to the destination site. The solution was to delete the two pages that cause the error.

To discover what page are causing the problem you can trace de Content Data Base of your site during the create hierarchies process. You will see that the variation process throws an SQLException due a violation of Primary Key on a table. This is the error that I saw in my event viewer and in the trace: Violation of PRIMARY KEY constraint 'PK__#ExportObjects____56256D26'. Cannot insert duplicate key in object 'dbo.#ExportObjects'.  The statement has been terminated.  If you save the trace in a table and launch a query like this SELECT * FROM MyStoredTrace WHERE TextData like '%name_of_origina_variant%' ORDER BY starttime it will return a lot of rows. To know what is the problematic page search the last processed page.

Another way to discover it is to review the site generated and determine what the first missing page is. It Is probable that this page produces an error when you try to move or copy.


 

Tuesday, April 10, 2007

How to acces to the Web Part Maintenance Page

You only have to append to the url of the page ?contents=1. I don't know the reason but it works.

Related Links:

http://www.google.com
J

Saturday, March 31, 2007

Inserting a contact item in a Contacts Lists in a subsite through the UpdateListItems web service

First let me tell you that in order to use the list's web service in a subsite you have to add ?WSDL to the URI of the web service. Example: http://server/subsite/_vti_bin/Lists.asmx?WSDL. If you do not append ?WSDL you will not receive any error, but will operate with the web service of the top level site instead of the subsite and you will not find your list in the subsite.

We will use a Contacts List template to save our contacts. It let us to synchronize with MS Outlook 2007 in order to view these contacts in out Address Book. You can see a method to accomplish it:


static
bool insertContact(string company, string address, string name, string surname, string email, string phone, string language)

{


 

PCM.Lists list = new PCM.Lists();

list.Credentials = new System.Net.NetworkCredential("user", "P@$$w0rd");


 

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();


 


XmlElement elBatch = doc.CreateElement("Batch");

elBatch.SetAttribute("OnError", "Continue");

elBatch.SetAttribute("ListVersion", "1");


 


XmlElement el1 = doc.CreateElement("Method");

el1.SetAttribute("ID", "1");

el1.SetAttribute("Cmd", "New");


 


XmlElement field1 = doc.CreateElement("Field");

field1.SetAttribute("Name", "Company");

field1.InnerText = company;


 


XmlElement field2 = doc.CreateElement("Field");

field2.SetAttribute("Name", "WorkAddress");

field2.InnerText = address;


 


XmlElement field3 = doc.CreateElement("Field");

field3.SetAttribute("Name", "FirstName");

field3.InnerText = name;


 


XmlElement field4 = doc.CreateElement("Field");

field4.SetAttribute("Name", "Title");

field4.InnerText = surname;


 


XmlElement field5 = doc.CreateElement("Field");

field5.SetAttribute("Name", "Email");

field5.InnerText = email;


 


XmlElement field6 = doc.CreateElement("Field");

field6.SetAttribute("Name", "WorkPhone");

field6.InnerText = phone;


 


XmlElement field7 = doc.CreateElement("Field");

field7.SetAttribute("Name", "WorkCountry");

field7.InnerText = language;


 


 

elBatch.AppendChild(el1);

el1.AppendChild(field1);

el1.AppendChild(field2);

el1.AppendChild(field3);

el1.AppendChild(field4);

el1.AppendChild(field5);

el1.AppendChild(field6);

el1.AppendChild(field7);


 


XmlNode rNode = list.UpdateListItems("Contacts", elBatch);


 


return
true;

}

Note: PCM is a Web Reference to our Lists.asmx web services.

Now you may synchronize the list with Outlook.

Related Links:

http://shlakapau.spaces.live.com/blog/cns!72ADBFE6717AFAF!107.entry

Thursday, March 29, 2007

KB932091 crashed my MOSS 2007

After an automatic update of WSS 3.0 my MOSS 2007 server crashed. I see these messages in my event viewer:

The message about the result of the installation was: Product: Microsoft Windows SharePoint Services 3.0 - Update 'Update for Microsoft WSS 3.0 (KB932091)' installed successfully.

The update cannot be started because the content sources cannot be accessed. Fix the errors and try the update again.

I solve it resetting the IIS.

Wednesday, March 21, 2007

SharePoint designer opens my site as a Web Site

It happens when you disable the Client Integation (Central Administration > Application Management > Authentication Providers > Edit Authentication). Then the site is opened as a normal web site and you cannot work with the SharePoint site properly.

Tuesday, March 20, 2007

Forms Server and the anonymous users

What would you do to enable forms server to unauthenticated users? When I have finished my form and tested it as anonymous user (as an authenticated user all works fine) I get an error when I submitted the form. My first idea was to follow the steps to enable the anonymous access to a list and submit my forms to this Document Library. But in SharePoint 2007 I could not grant access to lists to anonymous users. The only exception is the Surveys Lists (see the post in this blog).

The solution that I adopted was to change the submit option of my form. I published a web service that process the form and insert the form in a XML field on my database. If you want to save the form to a Document Library and avoid the database you can use the this web service or if you prefer you can store each field in a column of a Custom List extracting the fields of the form and insert in the list through the UpdateList web service published out-of-the-box by WSS 3.0

I also tried the solution exposed in post but it didn't work for me.

Related Links:

http://www.developer.com/services/article.php/3492456 (Web Service to process an InfoPath form)

http://support.microsoft.com/kb/927082/en-us (Enable anonymous access to a list)

http://www.sharepointblogs.com/ssa/archive/2006/11/30/16508.aspx (Upload files through web service)

http://jopx.blogspot.com/2006/08/using-webservices-in-browser-enabled.html (Forms Server)

http://weblog.vb-tech.com/nick/archive/2006/02/24/1453.aspx (WSS web services)

http://benreichelt.net/blog/2006/3/25/Insert-a-Sharepoint-list-item-from-web-services/ (Insert an item)


Thursday, March 8, 2007

Anonymous sites in MOSS 2007

One of the first problems I encountered when I began with SharePoint 2007 was the impossibility to show a list (doc lib, survey, pic lib, ...) to anonymous users. After configure the anonymous access for the site collection, site and list I only could show list to my authenticated users.

After googling I found the reason and the most important, the solution. By default the publish site collections ans all subsites has the LockDown mode on that makes that unauthenticated users cannot view lists.

The solution is simple, disable the LockMode. This action only will affect to the new sites that we create and the old sites still will continue with the LockMode on. To disable the LockMode you have to type:
stsadm -o deactivatefeature -url http://mysitecollection -filename ViewFormPagesLockDown\feature.xml

After that all sites created under the will have the LockMode off and theirs lists will be accessible by anonymous users.

Links:
http://technet2.microsoft.com/Office/en-us/library/f507f5d6-4c9d-4f98-909f-069c53b9a3f61033.mspx?mfr=true
http://www.sharepointplatform.com/teamblog/Lists/Posts/Post.aspx?List=427bfca2-b731-4c19-87c6-83c90460e02c&ID=29 (read until the end)

 
Online Visitors