Notes on SharePoint and CRM integration

January 29th, 2009 by radi a.

A came by a cool post today on http://www.sharepointusecases.com/ discussing basic integration possibilities between SharePoint and CRM. I thought it was worth mentioning:

http://www.sharepointusecases.com/index.php/2009/01/use-case-integrating-microsoft-office-sharepoint-with-microsoft-dynamics-crm/

Here's a few other idea's on use cases:

  • Delivering sales data to a SharePoint dashboard. Could also bring any data that is stored in CRM – support tickets, service activites, event details
  • Combining SharePoint sites with CRM entities – Project Workspaces, Account/Case documents in SharePoint, Product catalogue
  • MOSS Public Web Site integrated with CRM to manage events, support tickets, service agreements, enrollment for marketing lists or other subscriptions
  • Web parts pulling interesting and relevant statistics of CRM information to a MOSS intranet/portal

IE6 print CSS – PNG-24 with the AlphaImageLoader DX filter causing issues

January 27th, 2009 by radi a.
Technorati Tags: ,

If you're one of the criminals using IE6's print function, please upgrade. You are causing web developers extra headaches.

Yesterday I was solving a print styling issue in IE6. It basically looked wrong in IE6, so wrong that I couldn't even recognise the output. I noticed that elements with a DX filter (AlphaImageLoader) we're getting displaced.

The AlphaImageLoader DX filter is used to get IE6 render PNG-24 images correctly. Your CSS file might have the following property:

filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='bg.png', sizingMethod='crop');

So if you use PNG-24 images for backgrounds, and you are having issues styling the print CSS, try setting the filter to none:

filter:none;

I fixed this on a few elements and my print issues went away.

Detecting the last item in the row set of a Content Query Web Part

January 20th, 2009 by radi a.

It is a common scenario to have the need to render the last row item of the Content Query Web Part (CQWP) a bit different from other row items. You might be positioning div's and containers with margins and you may want the last row item to have different styles, exclude the last delimiter or include an extra link. Here is how I implemented this requirement by just using the CQWP with some XSL changes:

Solution Structure

The CWQP uses a few default XSL stylesheets to render its output: ItemStyle.xsl, ContentQueryMain.xsl and Header.xsl located in “/Style Library/XSL Style Sheets”. These items get deployed by the MOSS Publishing Feature. For this exercise I had to modify ItemStyle.xsl and ContentQueryMain.xsl, but instead of modifying the default files I created copies of them and included them in a feature that also deploys my instance of the CQWP.

My feature deploys the required XSL files to a custom folder under “XSL Style Sheets”, and the following properties of my CQWP are modified to reference those XSL files rather than the default ones.

<property name="HeaderXslLink" type="string">/Style Library/XSL Style Sheets/MOSSIGWebPart/MOSSIGWebPartHeaderStyle.xslt</property><property name="MainXslLink" type="string">/Style Library/XSL Style Sheets/MOSSIGWebPart/MOSSIGWebPartMainStyle.xslt</property><property name="ItemXslLink" type="string">/Style Library/XSL Style Sheets/MOSSIGWebPart/MOSSIGWebPartItemStyle.xslt</property>

XSL modifications

Inside the ContentQueryMain.xsl file there is a section that renders the body of the web part. The template is called “OuterTemplate.Body”. The template instantiates a convenient variable $CurPosition, and it passes it onto the item template “OuterTemplate.CallItemTemplate”.

<xsl:call-template name="OuterTemplate.CallItemTemplate">  <xsl:with-param name="CurPosition" select="$CurPosition" /></xsl:call-template>

The inconvenience is that inside "OuterTemplate.CallItemTemplate" the parameter is not actually passed to the custom template inside the ItemStyle.xslt file:

<xsl:otherwise>   <xsl:apply-templates select="." mode="itemstyle">   </xsl:apply-templates></xsl:otherwise>

To pass it through to the ItemStyle.xslt template I included the CurPosition parameter:

<xsl:otherwise>   <xsl:apply-templates select="." mode="itemstyle">      <xsl:with-param name="CurPosition" select="$CurPosition" />   </xsl:apply-templates></xsl:otherwise>

I made a matching declaration in my customised ItemStyle.xsl file to accept the parameter:

  <xsl:template name="MOSSIGStyle" match="Row[@Style='MOSSIGStyle']" mode="itemstyle">    <xsl:param name="CurPosition" />

I can then use this variable throughout my item template. A simple check can determine if the current row is the last row:

   <div id="linkitem" class="m-item">      <xsl:attribute name="style">        <xsl:if test="not($CurPosition = 3)">margin-top:10px;</xsl:if>        <xsl:if test="$CurPosition = 3">margin-top:0;</xsl:if>      </xsl:attribute>

I always had 5 items returned from query. Similar to the above approach you can bring the total row count if you have a situation where the amount of returned rows changes. OuterTemplate.Body privides the $LastRow parameter.

          <xsl:with-param name="LastRow" select="$LastRow" />

Has anyone approached this in any other way?

Creating a SharePoint variation hierarchy fails: “An error was encountered performing this operation”

January 19th, 2009 by radi a.

It doesn't give you much more details than the following message:

"An error was encountered performing this operation.  You may re-try the operation, and you may need to clean up the half-created data first before re-trying. If the problem persists, please contact your system administrator."

This error is much more severe than a simple "failure" in the Variation Logs – the Long Running Operation (LRO) that creates the hierarchy terminates half-way. It is also very easy to miss.

I've been working a bit with SharePoint variations and they are always tricky. The golden rule about variations (and content deployment) is to have good governance and clean content.  A messy content source will only cause headaches.

Here are the steps I took to solve the above issue:

I checked with my ugliest best friend – SharePoint's Unified Logging Service. The following lines are a bit hard to find, but they pointed me in the right direction. I have removed a lot of garbage between them, but kept the sequence:

CMS      Site Management         78ew    Medium            PublishingPage::CreateVariationInner() Begins. this: http://mossig /home/intranet/help/Pages/howto.aspx, varlabel: groups
CMS      Publishing        6wyq    Medium            GetFileFromUrl: ArgumentException when attempting get file Url http://staging/_catalogs/masterpage/HelpPage.aspx Value does not fall within the expected range.
CMS      Publishing        89v3    Exception         LRO – An unhandled exception was caught in ThreadEntryPoint System.ArgumentException: Value does not fall within the expected range.
CMS      Publishing        8ztq     Medium            LongRunningOperationJob.UpdateStatus(): Failed, this=35412716
CMS      Publishing        8ztq     Medium            LRO – Starting status update: Failed

Sometime the above lines are a bit hard to find (especially if you don't know what you are looking for!). There is usually a LOT of "Potentially excessive number of SPRequest objects" entries in between them because of the extra load that the LRO causes. I usually keep a note of the time of failure or even better, SPTraceView if I am watching over it in real time.

They provided me with enough information to identify the actual cause.

The <mso:PublishingPageLayout> property of the howto.aspx page was incorrect. The link to the Page Layout file was absolute, pointing to a staging server from the origination of the content.

<mso:PublishingPageLayout msdt:dt="string">http://staging /_catalogs/masterpage/HelpPage.aspx, Help Page</mso:PublishingPageLayout>

I did some research on why this is happening in the first place. The following articles had all the answers:

http://blogs.technet.com/stefan_gossner/archive/2008/03/12/common-error-situation-with-when-using-backup-restore-to-transfer-a-database-to-a-new-farm-on-moss-2007.aspx

http://blog.thekid.me.uk/archive/2007/08/20/fixing-page-layout-urls-after-importing-a-publishing-site-in-sharepoint.aspx

http://stsadm.blogspot.com/2007/08/fix-publishing-pages-page-layout-url.html

Content to staging was essentially restored via the backup/restore functionality, rather than export/import. This doesn't do great things to the page layout properties and essentially can break the variation feature.

The fix is simple – change the URL's to relative in all files that have absolute URL's.  You can either download the file and modify the property manually, use SharePoint Designer, or experiment with the code/tools by Gary Lapointe.

Once I fixed all content files the hierarchies created successfully.

 

Stretching images can be achieved with a percentage as a width/height value

January 17th, 2009 by radi a.

I keep forgetting about this really cool feature – image sizes can be proportionate to the browser window size and shrink/expand as you change the browser window size.

This can be very useful in many situations where fixed images cause difficulties in flexible/liquid site designs and layouts. Picture galleries are always a candidate for flexible thumbnail sizes.

A container (div) sized as a percentage (ie 50%) will stretch together with the browser and always be 50% of the viewable browser area. An image inside that container can be set to a percentage size, lets say 50%. This image will be rendered at 50% of its container size and will change as the container changes.

 Example:

div.container {width:50%;}

div.container img {width:50%}

As you stretch the browser, the image will grow.

This can have great effects when used in column designs where the column widths are flexible and a fixed image size won't look optimal in different screen resolutions. I used this when creating a web part with thumbnails that fits in a right column web part zone.

SharePoint error: Cannot convert type 'Microsoft.SharePoint.WebControls.DelegateControl' to 'System.Web.UI.IAttributeAccessor'

January 8th, 2009 by radi a.

 I got this error today while deploying a solution to a test environment:

"CS0030: Cannot convert type 'Microsoft.SharePoint.WebControls.DelegateControl' to 'System.Web.UI.IAttributeAccessor'"

Disabling SP's custom errors and turning on callstack in the web.config revealed the following:

Line 171:                          <!– <div id="login_box">

Line 172:                                   <SharePoint:DelegateControl id="AALogin" runat="server" ControlId="AALogin" __designer:Preview="&lt;span style=&quot;display:none&quot;&gt;&lt;/span&gt;" __designer:Values="&lt;P N='ControlId' T='TrafficDirectorLogin' /&gt;&lt;P N='ID' T='TDLogin' /&gt;&lt;P N='Page' ID='1' /&gt;&lt;P N='TemplateControl' ID='2' /&gt;&lt;P N='AppRelativeTemplateSourceDirectory' R='-1' /&gt;"/>Line 173:                          </div> –> 

The actual cause of the error was due to the garbage that SharePoint Designer added to the <SharePoint:DelegateControl> tag. Removing that control, which is in comments anyway, or fixing the markup solved the problem.

There's 2 quick lessons from this: (1) don't leave any controls in commented out areas – ASP.NET still processes them during the rendering methods, but the browser leaves them out; (2) Watch out for SharePoint Designer doing black magic to your HTML tags, it has the bad habit of breaking things.

Save Australia's Internet….

December 8th, 2008 by radi a.

I believe every internet user in Australia should sign this petition: http://www.getup.org.au/campaign/SaveTheNet/442

I don't want our ruling Government to introduce an internet censorship scheme that will not achieve it's intended purpose. Our internet in Australia is slow and expensive as it is. Bulgaria's internet is far more superior that Australia's.

Google Reader and IE problems

December 7th, 2008 by radi a.

Thanks to the person sitting next to me, Merill Fernando, I am now a happy user of Google Reader. The problem is that IE7 doesn't work well with it… Today I found another problem between the two:

Google Reader IE error

 Essentially, that means I can't add friends in my Google Reader when I'm using IE. Why do I use IE? Because my clients do. I actually use all FF, IE and Chrome, but tend to use IE for most of my work-related stuff + I can't use FF and C for SharePoint, Project Server and CRM stuff. I still think Google Reader should be compatible with IE, ~60% of web users browse via IE, right?

Oh yeah, feel free to become my friend: sharepoint dot radi at gmail dot com

SharePoint specific site Content Deployment: file cannot be imported because its parent web does not exist

December 2nd, 2008 by radi a.

I was working on some Content Deployment stuff and ran into a few problems, but I really wanted to describe the following one as I couldn't find much information on it.

The history log for the job showed errors but the information was incomplete. I got the following for an error:

“The file <> cannot be imported because its parent web <> does not exist”
Content Deployment error
 

But that item belongs to a site that I don't even want to export/import.

So why does Content Deployment want to include the item when I don't even have that site in my list?

Thanks to my colleague and drink-mate Ari Bakker I was pointed in the right direction. His blog article describes using the object model to get a dump of what the Content Deployment job is doing in the background. I created a simple console application and dumped his code. I modified it to only include the specific sites that I wanted, rather than the entire site collection:
  

SPWeb web = sitecollection.OpenWeb("/home");

SPExportObject homeWeb = new SPExportObject();

homeWeb.Id = web.ID;

homeWeb.IncludeDescendants = SPIncludeDescendants.Content; homeWeb.Type = SPDeploymentObjectType.Web; 

//settings is the SPExportSettings object as per Ari's code

settings.ExportObjects.Add(homeWeb);

After running the export code I ended up with lots of files in my export folder: a whole bunch of “.DAT” files that represent content files, and a few “.XML” files. The one that interested me was Manifest.xml – it is an XML representation of all of the SPObjects that get copied by the Content Deployment job. I could find the item that was failing inside Manifest.xml. In my particular instance the Content Deployment job was reporting on a “PublishingImages/Forms/Document” file that belongs to a site that I'm not trying to move across. I could locate the relevant SPObject + a few others related to it in the Manifest.xml file – SPFolder, SPContentType, SPListItem and SPFile belonging to that list item.

Content Deployment history 

The SPFile was a JPG image. Aha!

Doing a quick search inside the same file revealed another SPObject inside the site that I wanted to export/import – it was just a content page.The problem is apparent: the content deployment job will include any objects referenced by items in the scope of the job. It will export images in sites other than the ones specified in the export. The problem arises when the content deployment job tries to import these objects into the location that they belong to – but they aren't included in the scope of the job and their parent webs don't get copied over. This results in our error. The parent webs of those objects simply don't exist if there has never been a full deployment prior to this export/import. One workaround to this is to use the ExcludeDependencies property of the SPExportObject, this is described in Stefan Gossner's content deployment articles (problem 6). A more practical solution is to copy the image over to the site that you are exporting and edit the content to reference that image. Searching for all instances of the image inside Manifest.xml pointed me towards all SPObjects that reference it. Cleaning up the content solved the problem. Hope this helps someone.

Resources:

Read Ari's blog and drink with him!

Read Stefan Gossner's blog if you ever have to do anything with Content Deployment.

 

Error installing Project Server 2007 "Setup is unable to proceed…"

November 19th, 2008 by radi a.

I was going through a Project Server 2007 install and ran into this problem:

"Setup is unable to proceed due to the following error(s):

http://go.microsoft.com/fwlink/?LinkId=103318
Correct the issue(s) listed above and re-run setup."

After a bit of searching and following that link I ended up on this KB article: http://support.microsoft.com/kb/945967 The only thing is that it doesn't mention Project Server 2007, but Search Server 2008 and MOSS 2007.

I realised I was trying to install Project Server 2007 binaries with SP1 on an installation of WSS without SP1. It would seem that the error will appear in any WSS-based SP1 server package installation when WSS on the server does not include the service pack.

The obvious resolution was to install WSS SP1 then proceed with Project Server 2007 _with_ SP1. Would have been nice if that KB article mentions PS 2007