Saturday, August 26, 2017

Removing NOBR tags from a SharePoint 2010 page.

When editing a list item in a SharePoint 2010 list. If your column names are very long, the column label can take over the width of your screen, forcing you to scroll to see or update the column value. The following style entry should take care of the problem by setting your Label width column to an arbitrary width.

<style>
td.ms-formlabel 
{
   width: 35%; 
   white-space: normal;
}
</style>

 Unfortunately, this doesn't fix the problem when in edit view. The styling alone doesn't fix the problem because the EditForm.aspx pags contain the deprecated <NOBR> tags. The purpose of the <NOBR> tag was to prevent the containing text from wrapping. To solve the problem, you need to remove the <NOBR> tags with scripting, as shown below.

<script>
var nobr = document.getElementsByTagName("nobr");
for (i=0; i < nobr.length; i++)
{
  var ih = nobr[i].innerHTML;
  nobr[i].style.display = "none";
  var sp = document.createElement("span");
  sp.innerHTML = ih;
  nobr[i].parentElement.appendChild(sp);
}
</script>

The script takes the inner html of the NOBR tag, places it in a span, and then appends the span to the NOBR tag's parent. The NOBR tag is then hidden from view.

In later versions of SharePoint, these tags have been replaced with WHITE-SPACE styling.

Monday, August 29, 2016

LoginView Control in SharePoint Web Part

When developing on a SharePoint site, if you have the need to show your logged in users content that you don't necessarily want to show your anonymous users, the LoginView control is for you.

Keeping it simple, we pass a string to the LoggedInTemplate class constructor that inherits from the iTemplate interface.

// we'll show the label only when a user is logged in. Intended for employees only.
LoginView lv = new LoginView();
Label usernameLabel = new Label();
usernameLabel.Text = "Hello There";
lv.LoggedInTemplate = new LoginViewTemplate(usernameLabel);
Controls.Add(lv);

// Logged in user and anonymous templates inherited from iTemplate interface.
    class LoginViewTemplate : ITemplate
    {
        private Label _label;
        public LoginViewTemplate(Label label)
        {
            _label = label;
        }
        public void InstantiateIn(Control container)
        {
            container.Controls.Add(_label);
        }
    }

// not used in this example
    class AnonymousTemplate : ITemplate
    {
        private Label _label;
        public AnonymousTemplate(Label label)
        {
            _label = label;
        }
        public void InstantiateIn(Control container)
        {
            container.Controls.Add(_label);
        }
    }

For further filtering out your logged in users to see specific content, use RoleGroups instead.

Wednesday, August 17, 2016

Replacing parentheses in Haivision CoolSigns data table items

When using an RSS feed to populate a data table in Haivision CoolSigns, apostrophes will be replaced by its HTML encoded entity, "&apos;". When working with the data table in Content Creator, you'll need to use the following javascript to decode the HTML entity back to an apostrophe. Notice that the use of RegEx and the global flag is needed to catch multiple apostrophes.

return GetValueEx("title",rowindex,timeoffset,"").replace(/&apos;/g,"'")

Wednesday, February 24, 2016

Using Globally defined arrays in Crystal Reports

In Crystal Reports you can use a globally defined array to determine whether or not any given record will show on a report. Case in point, a record is pulled into your report multiple times due to a join condition. We want to suppress one of the records so only one shows on the report. In our case, we want to keep all records with note # 0033. If any record with note # 0033 is not duplicated with a different note number, that record we want to keep.

To begin, we'll want to initialize our variables in a function. This function is dropped in the Report header:

Global numberVar array ClassNumberArray;
Global numberVar CNCount := 1;
Redim ClassNumberArray[1];

The following function we will want to drop into the Details section of the report. This function runs during the Record Reading pass:

WhileReadingRecords;
Global numberVar CNCount;
Global numberVar array ClassNumberArray;
Redim preserve ClassNumberArray[CNCount];
ClassNumberArray[CNCount] := {RDS_CLASS_VW.CLASS_CLASS_NBR};
CNCount := CNCount + 1;

Our global array is now filled. The following function (we'll call it 'ClassNumber Count' and refer to it later) also gets dropped in the Details section of the report and we'll have it run during the next pass, the Record Printing pass.

WhilePrintingRecords;
Global numbervar array ClassNumberArray;
local numberVar j := 0;
numbervar i;

For i:=1 to Count(ClassNumberArray) do
    if ({RDS_CLASS_VW.CLASS_CLASS_NBR} = ClassNumberArray[i]) then
        j := j + 1;
j;

The variable "j" now holds the number of times that record is duplicated in the set of records.

Now in Section Expert, we'll create a rule for suppressing records:

{REC_CLASS_NOTES_VW.NOTES_NOTE_NBR} = "0033" and {@ClassNumber Count} > 1

// delete any records with note # 0033 that show up two times or more in the array.

That's it. When a record shows up more then once, the record with note # 0033 is the one that is removed.

Saturday, December 19, 2015

Rename files in a folder using VBScript

Like a lot of you, I take a lot of pictures with my cell phone which I like to upload to my desktop computer. Besides pictures from the cell phone, I also have a Canon PowerShot camera that I like to use as well. When I upload the pictures, I like to have easier control of how the files are named for sharing purposes. Below is a VBScript I use to rename an entire folder's worth of pictures. For ease-of-use, I use textboxes to enter the folder path and the filename prefix. The script then adds unique numbers, with leading zeroes, to preserve the current sort. It's written to handle up to 9999 files in a folder, which for all practical purposes, is enough.

Option Explicit

Dim folderPath
Dim filePrefix
Dim FSO
Dim FLD
Dim file
Dim oldFilename
Dim newFilename
Dim LeadingZeroString
Dim count
Dim uniqueNumber

On Error Resume Next
folderPath = InputBox("Enter the folder path where your files are located:") 
filePrefix = InputBox("Enter the new filename prefix:") 

' path needs to end with a path separator
If Right(folderPath,1) <> "\" Then
folderPath = folderPath & "\"
End If

' Replace any characters, illegal or otherwise. 
filePrefix = Replace(Replace(filePrefix," ","_"),"\","_")

Set FSO = CreateObject("Scripting.FileSystemObject")
Set FLD = FSO.GetFolder(folderPath) 
If Err.Number < 1 Then
' set the correct # of leading zeros based on number of files
If FLD.Files.Count > 999 Then 
   LeadingZeroString = "0000"         
Elseif FLD.Files.Count > 99 Then 
   LeadingZeroString = "000" 
Else
   LeadingZeroString = "00" 
End If

'loop through the file collection, renaming files
For Each file in FLD.Files
   oldFilename = file.Path
   count = count + 1
   uniqueNumber = Right(LeadingZeroString & CStr(count), Len(LeadingZeroString))
   newFilename = folderPath & filePrefix & "_" & uniqueNumber & "." & FSO.GetExtensionName(oldFilename) 
   'rename the file
   FSO.MoveFile oldFilename, newFilename
Next

Set FLD = Nothing
Set FSO = Nothing
Else
MsgBox (Err.Description)
End If

Wednesday, July 8, 2015

Recently I updated a few MS Access reports that used various grouping; by day, by week and by month. In the group footers I needed to add two textboxes to display visit counts by campus.  Below is the report, group by week.





To show the first day of each week, the following expression was placed in the group header:

=Format([Time_In]-Weekday([Time_In],2),"dd-mmm-yyyy")

To show the count for the campuses, I included the following expressions:

=Count(IIf([Campus]="Pecos" Or IsNull([Campus]),1,Null))
and
=Count(IIf([Campus]="Williams",1,Null))

I look for null value because the Williams campus is a recent addition and there exists records where campus is null. I could have also summed the results as with the following expression:

=Sum(IIf([Campus]="Pecos" Or IsNull([Campus]),1,0))





Tuesday, March 17, 2015

Exporting Crystal Report to XML

Saving a Crystal Report in XML format, based upon the default Crystal Report schema, along with an xsl transformation, is a great way to  create web-ready content.

Below is a snippet of xml generated by Crystal Reports. While in Crystal, go to Format Field to set a custom Name attribute as shown below:

<?xml version="1.0" encoding="UTF-8" ?>
<CrystalReport xmlns="urn:crystal-reports:schemas:report-detail"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:crystal-reports:schemas:report-detail http://www.businessobjects.com/products/xml/CR2008Schema.xsd">
<Group Level="1">
<GroupHeader>
<Section SectionNumber="0">
<Field Name="TERM" FieldName="GroupName ({Command.CLASS_TERM_CD})"><FormattedValue>Spring 2015</FormattedValue><Value>Spring 2015</Value></Field>
<Field Name="TERMCODE" FieldName="{Command.CLASS_TERM_CD}"><FormattedValue>4152</FormattedValue><Value>4152</Value></Field>
</Section>
</GroupHeader>
<Details Level="2">
<Section SectionNumber="0">
<Field Name="CLASSNAME" FieldName="{Command.CLASS_CLASS_NAME}"><FormattedValue>ENG102</FormattedValue><Value>ENG102</Value></Field>
<Field Name="CLASSNBR" FieldName="{Command.CLASS_CLASS_NBR}"><FormattedValue>38090</FormattedValue><Value>38090</Value></Field>
<Field Name="TITLE" FieldName="{Command.CRSE_COURSE_TITLE_LONG}"><FormattedValue>First-Year Composition</FormattedValue><Value>First-Year Composition</Value></Field>
<Field Name="STARTTIME" FieldName="{Command.CLASS_START_TIME1}"><FormattedValue> 4:00PM</FormattedValue><Value> 4:00PM</Value></Field>
<Field Name="ENDTIME" FieldName="{Command.CLASS_END_TIME1}"><FormattedValue> 6:40PM</FormattedValue><Value> 6:40PM</Value></Field>
<Field Name="STARTDATE" FieldName="{Command.CLASS_START_DATE}"><FormattedValue>3/24</FormattedValue><Value>2015-03-24T00:00:00</Value></Field>
<Field Name="ENDDATE" FieldName="{Command.CLASS_END_DATE}"><FormattedValue>5/15</FormattedValue><Value>2015-05-15T00:00:00</Value></Field>
<Field Name="DAYS" FieldName="{@FormattedDays}"><FormattedValue>Tu,Tr</FormattedValue><Value>Tu,Tr</Value></Field>
</Section>
</Details>

...


On the XSL side, make sure you setup your Crystal Reports namespace. In the example below I'm using a 'cr' prefix.

<?xml version="1.0"?><xsl:stylesheet xmlns:cr="urn:crystal-reports:schemas:report-detail" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="/">

<xsl:for-each select="cr:CrystalReport/cr:Group">

<h2 class="ms-rteElement-H2Custom"><xsl:value-of select="cr:GroupHeader/cr:Section/cr:Field[@Name='TERM']/cr:FormattedValue"/></h2><table width="100%" class="courseTableWP">
<xsl:for-each select="cr:Details/cr:Section">

<tr class="courseTableRow"></tr></xsl:for-each></table>
<th width="10%">Course</th><th width="15%">Class Number</th><th width="35%">Title</th><th width="10%">Days</th><th width="15%">Times</th><th width="15%">Dates</th>
<td><xsl:value-of select="cr:Field[@Name='CLASSNAME']/cr:FormattedValue"/></td>
<td><xsl:value-of select="cr:Field[@Name='CLASSNBR']/cr:FormattedValue"/></td>
<td><xsl:value-of select="cr:Field[@Name='TITLE']/cr:FormattedValue"/></td>
<td><xsl:value-of select="cr:Field[@Name='DAYS']/cr:FormattedValue"/></td>
<td><xsl:value-of select="cr:Field[@Name='STARTTIME']/cr:FormattedValue"/>- <xsl:value-of select="cr:Field[@Name='ENDTIME']/cr:FormattedValue"/></td>
<td><xsl:value-of select="cr:Field[@Name='STARTDATE']/cr:FormattedValue"/> - <xsl:value-of select="cr:Field[@Name='ENDDATE']/cr:FormattedValue"/></td>

</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Wednesday, December 10, 2014

Displaying the first day of the week in CoolSigns content

The following javascript can be used to display the first day of the current week in content created for CoolSigns.

var d = new Date();
var day = d.getDay();
var diff = d.getDate() - day + (day == 0 ? -6:1);
var monday = new Date(d.setDate(diff));

var month = monday.getMonth() == 0 ? "January":
monday.getMonth() == 1 ? "February":
monday.getMonth() == 2 ? "March":
monday.getMonth() == 3 ? "April":
monday.getMonth() == 4 ? "May":
monday.getMonth() == 5 ? "June":
monday.getMonth() == 6 ? "July":
monday.getMonth() == 7 ? "August":
monday.getMonth() == 8 ? "September":
monday.getMonth() == 9 ? "October":
monday.getMonth() == 10 ? "November":"December";

return month + " " + monday.getDate() + ", " + monday.getYear();

Using an OR Statement in Crystal Reports to suppress rows in the Details section


I recently created a report where I want to suppress rows in the Details section of a Crystal Report. Using an OR statement along with a conditional IF, besides suppressing based on duplicate ID values, I can also suppress the row based upon a parameter value.

{?Intended Audience} = "Internal Use Only"
OR
 if (not onfirstrecord) then (previous({PERSON.ID})={PERSON.ID})

Thursday, September 11, 2014

Using PowerShell to find the GUID of an SPField instance

In SharePoint, I occasionally need to find the GUID of a field in a custom list. The following PowerShell will spit out the field's GUID:


$web=get-spweb https://mysite.com/mysite/
$list=$web.lists["My List Display Name"]
$list.fields["MyFieldName"].id

Wednesday, August 27, 2014

Looking for at least one checked checkbox in Multiple-Selection List Box groups using X-Path in InfoPath


In a scenario involving multiple groups of Multiple-Selection List Boxes where I needed to check and see if at least one checkbox was checked in an InfoPath form, I used a Calculated Field to display a message if no checkboxes were checked. Checking for at least one box checked can be accomplished by using the following X-Path expression:

substring("Text to show if no checkboxes selected", 1, (not(boolean(xdMath:Eval(dfs:dataFields/my:SharePointListItem_RW/my:ListBox1/Value[. != ""], "."))) and
not(boolean(xdMath:Eval(dfs:dataFields/my:SharePointListItem_RW/my:ListBox2/Value[. != ""], "."))) and
not(boolean(xdMath:Eval(dfs:dataFields/my:SharePointListItem_RW/my:ListBox3/Value[. != ""], ".")))) *
string-length("Text to show if no checkboxes selected"))

The condition evaluates to True (1) if no boxes are checked, False (0) if any box is checked. These 1 or 0 values are multiplied by the length of the text and serve as the third parameter in the substring function, determining the length of the substring.

Wednesday, July 2, 2014

Formatting datetime datafields in CoolSign Content Creator

 
When using the current datetime or Data table datetime values for digital signage content in Haivision's CoolSigns Content Creator software, the following DateTime string patterns can be used:
 
MM/dd/yyyy - 08/22/2014 
dddd, MMMM dd yyyy - Tuesday, July 01 2014 
dddd, MMMM d yyyy HH:mm - Tuesday, July 1 2014 06:30 
dddd, MMMM dd yyyy hh:mm tt - Tuesday, July 01 2014 06:30 AM 
dddd, MMMM d yyyy H:mm - Tuesday, July 1 2014 6:30 
dddd, MMMM dd yyyy h:mm tt - Tuesday, July 01 2014 6:30 AM
ddd, MMM d yyyy h:mm tt - Tues, Jul 1 2014 6:30 AM
dddd, MMMM d yyyy HH:mm:ss - Tuesday, July 1 2014 06:30:07 
MM/dd/yyyy HH:mm - 08/22/2014 06:30 
MM/dd/yyyy hh:mm tt - 08/22/2014 06:30 AM 
MM/dd/yyyy H:mm - 08/22/2014 6:30 
MM/dd/yyyy h:mm tt - 08/22/2014 6:30 AM  
MM/dd/yyyy HH:mm:ss - 08/22/2014 06:30:07


In the Expression builder, the following javascript syntax can be used to format the datetime value:

return FormatDateStr(GetValueEx("localstart",rowindex,timeoffset,""),"h:mm tt")

If - Else statement in CoolSigns Datafield Expression

When using Data tables to add dynamic data to digital signage content in Haivision's CoolSign Content Creator software, it's important to know that the Expression builder editor excepts most javascript syntax. If - Else statements are permitted, below is an example:

if (GetValueEx("location",rowindex,timeoffset,"").indexOf("Away") > -1)
      return "Away Game"
else
      return "Home Game"

This example checks the value of "location" and assigns a value to the datafield based on that value.

Wednesday, April 16, 2014

Multiple if conditions in a Crystal Reports Record Selection


 When using multiple If statements in a Crystal Reports Record Selection, use parentheses to group your if-then-else statements. These need to be terminated with an Else. If no else exists in your logic, use Else True. Multiple If statements are then separated using an And or Or as seen in the example below:


{TERM} = {?Term} And
{INSTITUTION} = {?Institution} And
(
If ({?Organization} <> "%") Then
    {ACAD_ORG} = {?Organization}
Else True
)
And
(
If ({?Dual Enrollment} = "N") Then
    {HS_DUAL_ENROLL} = "N"
Else If ({?Dual Enrollment} = "Y") Then
    {HS_DUAL_ENROLL} = "Y"
Else True
)

Thursday, February 20, 2014

Updating SharePoint Ribbon Styles and Markup Styles

The SharePoint 2010 Ribbon contains default styles and elements in their Styles and Markup Styles sections. Using CSS, you can add styles or elements as well as hide OOTB styles and elements.

To create new items, use the ms-rteElement or ms-rteStyle prefixes in your CSS file.

H2.ms-rteElement-H2Custom
{
     -ms-name:Title;
     color:#008C99;
     background-color:transparent;
 }

.ms-rteStyle-Normal
{
      -ms-name:"Normal";
      font-size:10pt;
      font-weight:normal;
      background-color:transparent;
}

To remove the Styles button entirely:

#Ribbon\.EditingTools\.CPEditTab\.Styles
{
      display:none;
}

To remove a single element from the Markup Styles list (Change the ElementWithStyle index number to hide the element based on its order in the list.):

li.ms-cui-menusection-items a#ElementWithStyle0-Menu
{
      display:none;
}
li.ms-cui-menusection-items a#ElementWithStyle1-Menu
{
      display:none;
}

Thursday, January 30, 2014

Using rowspan, colspan and nested tables


Below is an example of constructing an HTML table using rowspan, colspan and nesting tables in a cell.


Enrollment Services Finances Take a Placement test
Testing Center
Advising
New Student Orientation
Finances
Become a Student How to Make a Payment Meet with an Advisor
How to Make a Loan Payment


<table  border="1" cellpadding="10">
<tr>
<td>Enrollment Services</td>
<td>Finances</td>
<td>Advising</td>
<td rowspan="4">
<table border="1" cellpadding="5">
<tr>
<td>Testing Center</td>
</tr>
<tr>
<td>New Student Orientation</td>
</tr>
<tr>
<td>New Student Orientation</td>
</tr>
<td>New Student Orientation</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>Become a Student</td>
<td>Enroll in a Class</td>
<td>Meet with an Advisor</td>
</tr>
<tr>
                <td colspan="2">How to Make a Loan Payment</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</table>

Wednesday, December 11, 2013

Using VLOOKUP function with datasource query in Excel

When using the VLOOKUP function on a table array with data returned from a data source query, I found it necessary to explicitly convert my lookup value to a text value. Failing to do so normally resulted in a error.


=VLOOKUP(TEXT(A1,0),Table_Query_from_My_Data_Source,2,FALSE)

Thursday, October 24, 2013

SharePoint Custom List web part template

A recent project involved adding the same navigation links to a couple of SharePoint blog sites. The navigation links must appear on the default.aspx, categories.aspx and post.aspx pages. Using a custom list in the parent site, we created a web part using SP Designer. Now, if we need another navigation web part for another set of blogs, we can simply export the web part and make the necessary changes. Below is the content of web part. Included is the xml definition of the view as well as the xsl to create the links.

<?xml version="1.0" encoding="utf-8" ?>
<webParts>
 <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
  <metaData>
   <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
   <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
  </metaData>
  <data>
   <properties>
    <property name="InitialAsyncDataFetch" type="bool">False</property>
    <property name="ChromeType" type="chrometype">None</property>
    <property name="Title" type="string" />
    <property name="Height" type="string" />
    <property name="CacheXslStorage" type="bool">True</property>
    <property name="XslLink" type="string" null="true" />
    <property name="AllowZoneChange" type="bool">True</property>
    <property name="AllowEdit" type="bool">True</property>
    <property name="XmlDefinitionLink" type="string" />
    <property name="DataFields" type="string" />
    <property name="Hidden" type="bool">False</property>
    <property name="ListName" type="string">{37683D39-B11D-4E11-8B1C-8C5421EDB458}</property>
    <property name="NoDefaultStyle" type="string">TRUE</property>
    <property name="ListDisplayName" type="string" null="true" />
    <property name="AutoRefresh" type="bool">False</property>
    <property name="ViewFlag" type="string">8388621</property>
    <property name="AutoRefreshInterval" type="int">60</property>
    <property name="AllowConnect" type="bool">True</property>
    <property name="Description" type="string" />
    <property name="AllowClose" type="bool">True</property>
    <property name="ShowWithSampleData" type="bool">False</property>
    <property name="ParameterBindings" type="string"></property>
     <property name="EnableOriginalValue" type="bool">False</property>
    <property name="CacheXslTimeOut" type="int">86400</property>
    <property name="WebId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">ef069fb2-2b0b-4c00-ad1f-231d5485f963</property>
    <property name="ListUrl" type="string" null="true" />
    <property name="DataSourceID" type="string" />
    <property name="FireInitialRow" type="bool">True</property>
    <property name="ManualRefresh" type="bool">False</property>
    <property name="ViewFlags" type="Microsoft.SharePoint.SPViewFlags, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Html, TabularView, Hidden, Mobile</property>
    <property name="ChromeState" type="chromestate">Normal</property>
    <property name="AllowHide" type="bool">True</property>
    <property name="PageSize" type="int">-1</property>
    <property name="SampleData" type="string" null="true" />
    <property name="BaseXsltHashKey" type="string">/_layouts/xsl/vwstyles.xsl;#12/13/2011 02:25:36;#0;#/_layouts/xsl/fldtypes.xsl;#03/26/2010 21:24:40;#0;#/_layouts/xsl/fldtypes_Ratings.xsl;#03/14/2012 11:19:12;#0;#/_layouts/xsl/fldtypes_docicon.xsl;#09/07/2011 11:41:41;#0;# 1 100  14.0.6120.5000</property>
    <property name="AsyncRefresh" type="bool">False</property>
    <property name="HelpMode" type="helpmode">Modeless</property>
    <property name="ListId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">37683d39-b11d-4e11-8b1c-8c5421edb458</property>
    <property name="DataSourceMode" type="Microsoft.SharePoint.WebControls.SPDataSourceMode, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">List</property>
    <property name="AllowMinimize" type="bool">True</property>
    <property name="TitleUrl" type="string">/XXXXX/XXX/Lists/Navigation</property>
    <property name="CatalogIconImageUrl" type="string" />
    <property name="DataSourcesString" type="string" />
    <property name="PageType" type="Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">PAGE_NORMALVIEW</property>
    <property name="DisplayName" type="string">All Items</property>
    <property name="UseSQLDataSourcePaging" type="bool">True</property>
    <property name="Width" type="string" />
    <property name="ExportMode" type="exportmode">All</property>
    <property name="Direction" type="direction">NotSet</property>
    <property name="ViewContentTypeId" type="string">0x</property>
    <property name="HelpUrl" type="string" />
    <property name="XmlDefinition" type="string">
    &lt;View Name="{E9A835C7-4605-41BD-AA5E-50D9799DE2C9}" MobileView="TRUE" Type="HTML" Hidden="TRUE" DisplayName="All Items" Url="/academic-affairs/AFA/SitePages/Untitled_12.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/generic.png"&gt;
     &lt;Query/&gt;
     &lt;ViewFields&gt;
      &lt;FieldRef Name="LinkTitle"/&gt;
      &lt;FieldRef Name="URL"/&gt;
      &lt;FieldRef Name="Title" Explicit="TRUE"/&gt;
     &lt;/ViewFields&gt;
     &lt;/View&gt;
    </property>   
     <property name="Xsl" type="string">
    &lt;xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office" ddwrt:ghost="show_all"&gt;
    &lt;xsl:template match="dsQueryResponse" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:o="urn:schemas-microsoft-com:office:office" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"&gt;       
     &lt;div class="AFANavigation"&gt;&lt;xsl:apply-templates select="/dsQueryResponse/Rows/Row"/&gt;&lt;/div&gt;
    &lt;/xsl:template&gt;
       &lt;xsl:template match="Row"&gt;
      &lt;xsl:choose&gt;
       &lt;xsl:when test="substring(@URL,2,3) = 'a h'"&gt;
        &lt;xsl:variable name="link" select="substring-after(substring-before(@URL,'&amp;lt;/a&amp;gt;'),'&amp;gt;')"/&gt;
        &lt;div&gt;&lt;a href="{$link}"&gt;&lt;xsl:value-of select="@Title"/&gt;&lt;/a&gt;&lt;/div&gt;
       &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
       &lt;div&gt;&lt;a href="{@URL}"&gt;&lt;xsl:value-of select="@Title"/&gt;&lt;/a&gt;&lt;/div&gt;
      &lt;/xsl:otherwise&gt;
     &lt;/xsl:choose&gt;
        &lt;/xsl:template&gt;
    &lt;/xsl:stylesheet&gt;
    </property>

    <property name="Default" type="string">FALSE</property>
    <property name="TitleIconImageUrl" type="string" />
    <property name="MissingAssembly" type="string">Cannot import this Web Part.</property>
    <property name="SelectParameters" type="string" />
   </properties>
  </data>
 </webPart>
</webParts>

Wednesday, October 9, 2013

Sharing variables between a subreport and the main report in Crystal Reports

In a recent  Crystal Report I was working on, I had a need to share a variable between a subreport and the main report so I could suppress rows based upon the value returned in the subreport. Normally, any value within a subreport is not visible to the Formula Editor. The key is to then to use a shared variable to pull the data into the main report where it's visible within the editor.

Because in the normal processing flow, subreports are exectuted in the 2nd pass, after record retrieval,

Friday, September 20, 2013

Using the following-sibling to compare node-sets in a SharePoint list


In a table I need to display items from a SharePoint custom list grouped by a column. For styling purposes, I need to identify the last row of each grouping. Using the following-sibling axis, I can look ahead to see if the group value will change. If so, I apply a class to the current table row.

<xsl:template match='Row'>
<tr>
<xsl:if test="@Group != following-sibling::Row[1]/@Group or position() = last()">
     <xsl:attribute name="class">lastItem</xsl:attribute>
 </xsl:if>
....
</tr>
...
</xsl:template>

In my stylesheet, I can then apply rules to the lastItem class:

table  tr { border-bottom: 2px #707070 dotted; }
table tr.lastItem { border-bottom: none; }