Tuesday, November 27, 2012

Show attachment from Remedy in .NET web app

We have a BMC Remedy form that contains classroom information along with jpg or gif attachments. To pull these images from the Remedy form into a .NET web application, use the following code:


            byte[] content = null;
            server.GetEntryBLOB("AssetRooms", id, 536880917, out content);
           
            string base64String = Convert.ToBase64String(content, 0, content.Length);

            if (base64String.Equals(""))
            {
                Label1.Text = "<br/><br/> Map not available.";
                Image1.Visible = false;
            }
            else
            {
                Image1.ImageUrl = "data:image/png;base64," + base64String;
                Image1.Visible = true;
            }

Image1 is an Image control:

<asp:Image ID="Image1" runat="server" Height = "380"/>

Friday, November 16, 2012

XSL for SharePoint List webparts

For out-of-the-box SharePoint List webparts, the 'XSL Link' property allows editors to customize the display of their list data.

Below is an example of an xsl stylesheet for list webparts.

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  exclude-result-prefixes="msxsl"
  xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="yes"/>

<xsl:template match="dsQueryResponse" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">
  <div class="resourcesList" >
      <xsl:apply-templates select="/dsQueryResponse/Rows/Row"/>
  </div> 
</xsl:template>

<xsl:template match="Row">
    <xsl:if test="position()=1">
    <h2><xsl:value-of select="@Category" disable-output-escaping="yes" /></h2>
    </xsl:if>
    <a href="{substring-before(substring-after(@URL,'&gt;'),'&lt;')}">
     <xsl:value-of select="@Title" disable-output-escaping="yes" />
    </a> <br/>
</xsl:template>

</xsl:stylesheet>

Using XSLT gives a much cleaner and customized look to your list webparts.


Friday, November 9, 2012

Launch your web browser as a different user

I often need to sign into SharePoint or another local server as a different user. An easy way to do this without logging out of your computer is to use the 'runas.exe' command. open a command prompt and enter the following command:

runas.exe /u:domain\username "C:\Program Files\Internet Explorer\iexplore.exe"

substitute domain\username with your account you want to login in with, I use a test account made specifically for these situations.

Monday, November 5, 2012

RANK function to create primary key for a Remedy View Form

To create Remedy View Form, you will need a database table or view that contains a numeric primary key. Since your table or view might not have a column that fits this requirement, you may need to dynamicall y create one in the building of the view.

Use the RANK function to create an incrementing value and then cast it as a an integer:

CAST(RANK() OVER(ORDER BY TERM,CAMPUS,BUILDING,ROOM,CRS_PREFIX,CRS_NUMBER,CRS_SUFFIX) AS int) AS Record

Thursday, October 18, 2012

AttachmentField control in SharePoint


The SharePoint AttachmentsField is used to display attachments from an SP list item.

<td align="center" id="att_{@ID}">
<xsl:if test="@Attachments='1'">
<SharePoint:AttachmentsField ID="att{@ID}" ControlMode="Display" ListId="{$ListID}" ItemId="{@ID}" FieldName="Attachments" visible="true" runat="server" />
</xsl:if>
</td>

The HTML that is rendered includes a table with a row for each attachment. The anchor tag look something like:

<a href="/student-affairs/athletics/athletics-w/basketball/Lists/Schedule/Attachments/11/statistics.html">20090312.6.html</a>

Mod operator to control Table Rows in XSL


The Mod operator returns the remainder left after division is performed. If you have a table and you need to have a certain amounts of columns before another row is created, use the mod operator.

The following example will create a new row after 3 columns are created.

<xsl:if test="position() mod 3 = 1">
<xsl:text disable-output-escaping="yes"><![CDATA[ <tr> ]]></xsl:text>
</xsl:if>
   <td valign="top">
    <img alt="" src="{@ImgURL}"/>
    <xsl:call-template name="dvt_2" />
   </td>
<xsl:if test="position() mod 3 = 3">
<xsl:text disable-output-escaping="yes"><![CDATA[ </tr> ]]></xsl:text>
</xsl:if>

Monday, September 24, 2012

Customizing the Summary Links with custom itemStyles.xslt


The Summary Links control (PublishingWebControls:summarylinkfieldcontrol) allows you to specify your own styles using the ItemXslLink property as shown below. 

<PublishingWebControls:summarylinkfieldcontrol ItemXslLink="/Style Library/XSL Style Sheets/InsideHomeItemStyle.xsl" .../>

In SP Designer, you can copy an existing xsl file and rename it, you can then update the file with your own styles and template names.

As a demo of how this works, the following New Home page layout has two Summary Link areas.


The custom itemStyles.xsl file I created has only 2 styles to chose from; insideHome1 & insideHome2. Both styles include a bullet icon in front of the link but insideHome1 colors the link teal, insideHome2 colors the link orange.

If you have a Links Webpart that you've added to a zone in your publishing page, you can export the webpart and modify the webpart file with the following xml:


<property name="HeaderXslLink" type="string">/Style Library/XSL Style Sheets/CustomHeader.xsl</property>
<property name="ItemXslLink" type="string">/Style Library/XSL Style Sheets/CustomItemStyle.xsl</property>

Save, add and upload your webpart. Your new header and styles will now be available.