cloud.net

Monday, February 4, 2008

Word of the day is PEBKAC

PEBKAC is an acronym which stands for "Problem Exists Between Keyboard And Chair".[1] The phrase is used by computer experts as a semi-humorous[2] way to describe user errors.

Other variations are POBCAC ("Problem Occurs Between Computer and Chair"), PIBKAC ("Problem Is Between Keyboard And Chair"), PEBCAC ("Problem Exists Between Chair and Computer"), PEBMAC ("Problem Exists Between Monitor And Chair"), PEBCAK ("Problem Exists Between Chair And Keyboard"), or EBKAC ("Error Between Keyboard And Chair") and also PICNIC ("Problem In Chair Not In Computer"). The occasionally seen variant PEBKAM ("Problem Exists Between Keyboard and Monitor") would appear to be based on a misunderstanding or misremembrance of the phrase. In 2006, Intel began running a number of PEBKAC web-based advertisements to promote their vPro platform.

Source: Wikipedia

Tuesday, January 29, 2008

Enabling HTML and/or Images in a SharePoint List using a calculated field

A client asked me to highlight a row based on the value of a status field... If figured easy, just use a dataview wp, but no, they want to be able to maintain it without using SPDesigner. I always like to give clients what they want, and I wasn't about to tell them to start changing the dataview in notepad... The "proper" way to enable HTML would probably be to create a bew custom field type, but since we need a formula this is not a trivial task; there is however a file which controls the way fields are rendered (see previous post).

We need to modify this to stop sharepoint encoding the HTML. This method has zero performance impact and only takes a few minutes.

To do this the first step is to open \Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\XML\FLDTYPES.XML
There are a couple of ways to change FLDTYPES.XML that will stop it encoding HTML; the one I've chosen is to look for a hidden tag in the value returned by a calculated field.
You can change any field type, but I need to change the calculated field type as I need to use conditional formating based on a formula.
  1. Locate <FieldName="TypeName">Calculated</Field> in FLDTYPES.XML.
  2. Move down to the <RenderPattern Name="DisplayPattern"> node.
  3. Find the <Default> node.
  4. Add your logic between the <Default> and </Default> nodes.
You can use various functions and properties to enable your logic, please see http://msdn2.microsoft.com/en-us/library/ms439798.aspx for a list. In my case I just needed an If Else as I didn't want to impact on existing calculated fields, so I opted for the <IfSubString> function, as follows:

<IfSubString>
<Expr1><![CDATA[<.RP>]]></Expr1>
<Expr2><Column/></Expr2>
<Then><HTML><Column/></HTML></Then>
<Else><Column HTMLEncode="TRUE" AutoHyperLink="TRUE" AutoNewLine="TRUE"/></Else>
</IfSubString>


The above basically means if the data in the column contains <.RP> then just render the contents. Otherwise do the MOSS default.

You could of course complicate the above and use a switch with <GetFileExtension> like:

<Switch>
<Expr><GetFileExtension><Column/></GetFileExtension></Expr>
<Case Value="RP>">
<HTML><Column/></HTML>
</Case>
<Default>
<Column HTMLEncode="TRUE" AutoHyperLink="TRUE" AutoNewLine="TRUE"/>
</Default>
</Switch>


The above has the benfit of allowing different logic for different scenarios.
The final step is to create a calculated field that returns <.RP>. Any record with this tag will enable the logic, and since <.RP> is an unknown tag browsers won't render it.
Using <GetFileExtension> you need to make sure your <.RP> is at the end.
The calculated field formula will look something like:

=IF([Active],"<.RP><b style='color:0000ff'>","<.RP><b style='color:ff0000'>") & [Title] &" "& [Column1] &" "& [Column2] &"</b>"

Look here for formulas http://msdn2.microsoft.com/en-us/library/bb862071.aspx

Now just create a view with just your calculated field and you have a list highlighting active records (with limited sorting)... but you could always just create a calculated field for each.

OK now you've probably realized your filtering has HTML... the fix for that is to disable filtering if the column has your tag... create a variable (<SetVar Scope="Request">) in your logic and set it, then check if it's been set outside <RenderPattern> set <Field Name="Filterable">FALSE</Field>. I haven't figured out how to render the heading as it displays without using Javascript... I could write this up one days. Notes: CAML is case sensative, and you'll need to restart IIS for any change to FLDTYPES.XML.

Modify FldTypes.xml to add custom field types and/or change display properties

FldTypes.xml

Each front-end Web server in a deployment of Windows SharePoint Services has one FLDTYPES.XML file located in the Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\XML folder that is used during site or list creation to define how field types are rendered in the different modes for viewing list data.

File Format

The following excerpt outlines the format of FLDTYPES.XML:

Xml
<FieldTypes>
  <FieldType>
    <Field Name="TypeName">Counter</Field>
    <Field Name="TypeDisplayName">$Resources:core,fldtype_counter;</Field>
    <Field Name="InternalType">Counter</Field>
    <Field Name="SQLType">int</Field>
    <Field Name="ParentType"></Field>
    <Field Name="UserCreatable">FALSE</Field>
    <Field Name="Sortable">TRUE</Field>
    <Field Name="Filterable">TRUE</Field>
    <RenderPattern Name="HeaderPattern">
      ...
    </RenderPattern>
    <RenderPattern Name="DisplayPattern">
      ...
    </RenderPattern>
    <RenderPattern Name="EditPattern">
      ...
    </RenderPattern>
    <RenderPattern Name="NewPattern" DisplayName="NewPattern">
      ...
    </RenderPattern>
    <RenderPattern Name="PreviewDisplayPattern">
      ...
    </RenderPattern>
    <RenderPattern Name="PreviewEditPattern">
      ...
    </RenderPattern>
    <RenderPattern Name="PreviewNewPattern">
      ...
    </RenderPattern>
  </FieldType>
  <FieldType>
    ...
  </FieldType>
  ...
</FieldTypes>

RenderPattern elements define how an item is displayed in each of the possible modes for viewing list data. These modes include the header patterns used at the top of each list in the toolbar, the modes used in forms for displaying, editing, or creating items, and preview rendering patterns used by a Web-editing application that is compatible with Windows SharePoint Services, such as Microsoft Office SharePoint Designer 2007.

To create a custom field that derives from a base field type, you can add a field definition to the Schema.xml file of a custom list definition Feature. For a programming task that shows how to add a field to a custom list definition, see How to: Create a Custom List Definition. For information about creating a custom field type, see Custom Field Types.

Monday, January 28, 2008

Universal Audio Architecture (UAA) High Definition Audio KB888111 for WinXP SP3

I couldn't get audio working on my laptop with SP3 as it's a Realtek HD, which relies on KB888111 and MS forgot to include it in SP3. Link: KB888111_SP3.zip thanks to redxii Usage: Win + R > devmgmt.msc > update audio driver and point to the contents on the KB888111_SP3.zip

Sunday, January 27, 2008

Creating and deploying a sharepoint solution package without command line tools

OK so you're a SharePoint developer, and you don't like using command line tools... some think you can't create a solution file and deploy it without using at least makecab or stsadm, but this isn't the case. What you need to create the solution file (wsp) and deploy it:

  1. Cabpack is a GUI cab compression tool using the MS cab engine.
  2. Either stsadmWin this adds a UI and sends the commands to stsadm or sharepoint solution intinstaller

Create your dll, create a manifest.xml cab it up using cabpack and follow the prompts with sharepointinstaller.

I came about this while trying to debug a solution deployment... read my previous post.

Cabpack has been very useful for quickly fixing/editing site templates. And has also help reduce site templates size to 1/3 using LZX compression type.

An error occurred while parsing EntityName

An error occurred while parsing EntityName. Line 11, position 65. RSSRipper.wsp: The Solution installation failed. I racked my brain over the above error for a couple of hours (OK maybe 30mins) until I realized the elements.xml file in my solution had an unescaped ampersand.
Fix: Change & for &amp;

Get Publik Key

Like most people you probably use reflector to get the public key, but there's an easier way...
  1. In Visual Studio 2005, click Tools -> External Tools...
  2. Click Add and enter the following into the different fields as displayed in the following: Title: Get Public Key Command: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe Arguments: -Tp "$(TargetPath)" Uncheck all options, except Use Output window\
Idea source: http://msdn2.microsoft.com/en-us/library/bb861799.aspx