Archive for the ‘Deployment’ Category

I just like to start by saying that this post is not ground breaking. However, when I tried to do this it did take me a while to find the answer, so I thought I’d just blog to add it to the grey matter.

As I’m sure you are all aware you can provision multiple files with preconfigured web parts by using a SharePoint module’s element file and a web part page as a template, by targeting the web part zones on the web part page.

However, trying to connect these caused me a bit of problems. In the end though it was quite straight forward. And can be done by specifying the following attributes in the code snippets and the descriptions given in the table below.

WebPartConnection
  1. <WebPartConnection ConsumerConnectionPointID="MediaSearchConsumer" ConsumerID="MediaResultsWebPart"
  2.                          ProviderConnectionPointID="MediaSearchProvider" ProviderID="MediaSearchWebPart" ID="MediaSearchConnector"/>

Web Part Consumer
  1.       <AllUsersWebPart WebPartZoneID="MiddleZone2" WebPartOrder="0" ID="MediaResultsWebPart">
  2.         <![CDATA[<?xml version="1.0" encoding="utf-8"?>
  3. <webParts>
  4.   <webPart xmlns="http://schemas.microsoft.com/WebPart/v3"&gt;
  5.     <metaData>
  6.       <type name="Instalec.SharePoint.WebParts.MediaResultsWebPart.MediaResultsWebPart, Instalec.SharePoint.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9e5b38b443f03fff" />
  7.       <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
  8.     </metaData>
  9.     <data>
  10.       <properties>
  11.         <property name="Title" type="string">Media Search Results</property>
  12.         <property name="Description" type="string">Web part to display the results from the media search</property>
  13.          <property name="Hidden" type="bool">True</property>
  14.           <property name="AllowHide" type="bool">True</property>
  15.       </properties>
  16.     </data>
  17.   </webPart>
  18. </webParts>
  19. ]]>
  20.       </AllUsersWebPart>

Web Part Provider
  1.     <AllUsersWebPart WebPartOrder="1" WebPartZoneID="MiddleZone" ID="MediaSearchWebPart">
  2.             <![CDATA[<webParts>
  3.   <webPart xmlns="http://schemas.microsoft.com/WebPart/v3"&gt;
  4.     <metaData>
  5.       <type name="Instalec.SharePoint.WebParts.MediaSearchWebPart.MediaSearchWebPart, Instalec.SharePoint.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9e5b38b443f03fff" />
  6.       <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
  7.     </metaData>
  8.     <data>
  9.       <properties>
  10.         <property name="Title" type="string">Media Search</property>
  11.         <property name="Description" type="string">My Visual WebPart</property>
  12.       </properties>
  13.     </data>
  14.   </webPart>
  15. </webParts>
  16. ]]>
  17.         </AllUsersWebPart>

Connection Consumer Attribute
  1. [ConnectionConsumer("The Search Criteria", "MediaSearchConsumer")]
  2.         public void IMediaSearchConsumer(IMediaSearch mediaSearch)

Connection Provider
  1. [ConnectionProvider("The Search Criteria", "MediaSearchProvider")]
  2.      public IMediaSearch IMediaSearchProvider()
  3.      {
  4.          return this;
  5.      }

 

ConsumerID ID specified in the AllUserWebPart element as seen in the Web Part Consumer above
ConsumerConnectionPointID The ID of the ConnectionConsumerAttribute seen above
ProviderID ID specified in the AllUserWebPart element as seen in the Web Part Provider above
ProviderConnectionPointID The ID of the ConnectionProviderAttribute seen
above
ID This can be any value but will not work without it

Job done… Smile

Okay, before anyone comments on the simplicity of this posting. It merely t allow me to get the script easily in the future.  What’s the purpose of it? It basically retracts a solution and waits until its fully retracted, then deletes it, adds it in again and redeploys it. Not rocket science, but handy. 

#Set up Web Application variable
#Only needed if solution contains Web Application scoped resources

$webApp = "
http://sitetodeployto"

#Set up solution name variable
$solutionName =  "solution.wsp"

#Set up solution file path variable
$filePath = "C:\Deploy51011\" + $solutionName

#Uninstall solution
#Add -WebApplication $webApp if solution contains Web Application scoped resources

Uninstall-SPSolution –Identity $solutionName –WebApplication $webApp  -Confirm:$false

#set up a variable for the solution to allow access to properties
$solution = Get-SPSolution $solutionName

#Wait for solution to be uninstalled
do {Start-Sleep -s 1} while ($solution.Deployed -eq $true)

# add another couple of seconds
Start-Sleep -s 2

#Remove solution from the farm without prompting
Remove-SPSolution $solutionName -Confirm:$false

# add it back in and deploy it
Add-SPSolution –LiteralPath $filePath
Install-SPSolution –Identity $solutionName –WebApplication $webApp –GACDeployment

Hope this saves someone some time Winking smile

Scenario: You want to us the inherited title field in your list definition,but you don’t want it to be called title.  To override what is displayed in the new/edit form is straight forward enough. You just add the DisplayName attribute to your Title FieldRef with the ID of {fa564e0f-0c70-4ab9-b863-0177e6ddd247} in the Content Type.

Overriding Title Display Name
  1. <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="New name" Required="FALSE" ShowInNewForm="TRUE" ShowInEditForm="TRUE" />

This is great and easy to achieve. However, you are still left with the column heading of Title in the list. This can be changed manually through the UI, but if you are constantly deploying that is not a solution.

To try and resolve this issue I changed the display name of the field ref in the view, but, as far as I can see, this does nothing at all. 

List Definition View Field
  1.   <FieldRef Name="LinkTitle" DisplayName="New Column Header">
  2.           </FieldRef>

In the end, I changed it manually and viewed the whole schema using SharePoint Manager 2010 . I discovered among the Schema.xml that SharePoint adds a computed column for the link title with the display name I added.

So, in essence, if you want to change the Title column value of a View add this to the fields section of the Schema.xml of the Definition.   

Overriding Title Heading XML
  1. <Field ID="{82642ec8-ef9b-478f-acf9-31f7d45fbc31}" ReadOnly="TRUE" Type="Computed" Name="LinkTitle" DisplayName="New Column Header" DisplayNameSrcField="Title" ClassInfo="Menu" AuthoringInfo="(linked to item with edit menu)" ListItemMenuAllowed="Required" LinkToItemAllowed="Prohibited" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitle" FromBaseType="TRUE">
  2.         <FieldRefs>
  3.           <FieldRef Name="Title" />
  4.           <FieldRef Name="LinkTitleNoMenu" />
  5.           <FieldRef Name="_EditMenuTableStart2" />
  6.           <FieldRef Name="_EditMenuTableEnd" />
  7.         </FieldRefs>
  8.         <DisplayPattern>
  9.           <FieldSwitch>
  10.             <Expr>
  11.               <GetVar Name="FreeForm" />
  12.             </Expr>
  13.             <Case Value="TRUE">
  14.               <Field Name="LinkTitleNoMenu" />
  15.             </Case>
  16.             <Default>
  17.               <Switch>
  18.                 <Expr>
  19.                   <GetVar Name="MasterVersion" />
  20.                 </Expr>
  21.                 <Case Value="4">
  22.                   <HTML><![CDATA[<div class="ms-vb itx" onmouseover="OnItem(this)" CTXName="ctx]]></HTML>
  23.                   <Field Name="_EditMenuTableStart2" />
  24.                   <HTML><![CDATA[">]]></HTML>
  25.                   <Field Name="LinkTitleNoMenu" />
  26.                   <HTML><![CDATA[</div>]]></HTML>
  27.                   <HTML><![CDATA[<div class="s4-ctx" onmouseover="OnChildItem(this.parentNode); return false;">]]></HTML>
  28.                   <HTML><![CDATA[<span>&nbsp;</span>]]></HTML>
  29.                   <HTML><![CDATA[<a onfocus="OnChildItem(this.parentNode.parentNode); return false;" onclick="PopMenuFromChevron(event); return false;" href="javascript:;" title="Open Menu"></a>]]></HTML>
  30.                   <HTML><![CDATA[<span>&nbsp;</span>]]></HTML>
  31.                   <HTML><![CDATA[</div>]]></HTML>
  32.                 </Case>
  33.                 <Default>
  34.                   <HTML><![CDATA[<table height="100%" cellspacing="0" class="ms-unselectedtitle itx" onmouseover="OnItem(this)" CTXName="ctx]]></HTML>
  35.                   <Field Name="_EditMenuTableStart2" />
  36.                   <HTML><![CDATA["><tr><td width="100%" class="ms-vb">]]></HTML>
  37.                   <SetVar Name="ShowAccessibleIcon" Value="1" />
  38.                   <Field Name="LinkTitleNoMenu" />
  39.                   <SetVar Name="ShowAccessibleIcon" Value="0" />
  40.                   <HTML><![CDATA[</td><td><img src="/_layouts/images/blank.gif" width="13" style="visibility:hidden" alt=""/></td></tr></table>]]></HTML>
  41.                 </Default>
  42.               </Switch>
  43.             </Default>
  44.           </FieldSwitch>
  45.         </DisplayPattern>
  46.       </Field>

Not, rocket science, but a bit of a pain…

Short one:  A bit of a vague error, “Failed to do column assignments for list”, found in the SharePoint logs after trying to deploy as solution. The solution contained many list definitions, instances and content types and when deployed it was notice that one of the list was missing. I’m sure there could be many reasons for this error as it does seem a bit generic, but in this instance it was caused by either a wrong or a duplicate value being specified in the ColName attribute of a field in the list definition.
ColName Attribute
  1. ColName=nvarchar21 RowOrdinal=0>
This is not an attribute I would add manually, but some of the solution had been reverse engineered from a list. Removing this attribute resolved the problem. SharePoint will assign a value to this itself and is not needed in the XML