Thursday, November 17, 2011

SHARE POINT QUERIES (ORG CHART)

Brief Background :  I am working in TR (India/Bangalore). The SPS sites are hosted in the server by share point admin and i do not have capability to change the master content, but i am able to change the settings only for the sub sites for which i have been provided with admin rights. I found your article on Org Chart SPS very helpful. I tried to mimic the procedure provided by you in your blog, but was unable to see the output as you mentioned in your blog. Below is the output which i am seeing after applying the XLS and Content Code.

Kindly help me..... Thanks a lot Josh....

a) The Names appear 8 Times in the SPS view

b) Source Code is as below



<%@ Page language="C#" MasterPageFile="~masterurl/default.master"    Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
<SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,multipages_homelink_text%>" EncodeMethod="HtmlEncode"/> -
<SharePoint:ProjectProperty Property="Title" runat="server"/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageImage" runat="server"><IMG SRC="/_layouts/images/blank.gif" width=1 height=1 alt=""></asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
<label class="ms-hidden">
<SharePoint:ProjectProperty Property="Title" runat="server"/></label>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderTitleBreadcrumb" runat="server"/>
<asp:Content ContentPlaceHolderId="PlaceHolderTitleAreaClass" runat="server">
<style type="text/css">
TD.ms-titleareaframe, .ms-pagetitleareaframe {
height: 10px;
}
Div.ms-titleareaframe {
height: 100%;
}
.ms-pagetitleareaframe table {
background: none;
height: 10px;
}
</style>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
<META Name="CollaborationServer" Content="SharePoint Team Web Site">
<script type="text/javascript">
var navBarHelpOverrideKey = "wssmain";
</script>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderSearchArea" runat="server">
<SharePoint:DelegateControl runat="server"
ControlId="SmallSearchInputBox"/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderLeftActions" runat="server">
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageDescription" runat="server"/>
<asp:Content ContentPlaceHolderId="PlaceHolderBodyAreaClass" runat="server">
<style type="text/css">
.ms-bodyareaframe {
padding: 0px;
}
</style>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<table cellspacing="0" border="0" width="100%">
 <tr>
  <td class="ms-pagebreadcrumb">
<asp:SiteMapPath SiteMapProvider="SPContentMapProvider" id="ContentMap" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional" runat="server"/>
  </td>
 </tr>
 <tr>
  <td class="ms-webpartpagedescription">
<SharePoint:ProjectProperty Property="Description" runat="server"/></td>
 </tr>
 <tr>
<td>
<table width="100%" cellpadding=0 cellspacing=0 style="padding: 5px 10px 10px 10px;">
 <tr>
  <td valign="top" width="70%" style="height: 499px">
  <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Left" Title="loc:Left"><ZoneTemplate>
<WebPartPages:ContentEditorWebPart runat="server" __MarkupType="xmlmarkup" WebPart="true" __WebPartId="{2F31165E-FC13-4A91-B37F-B8518FE4FE0D}" >
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
  <Title>Content Editor Web Part</Title>
  <FrameType>Default</FrameType>
  <Description>Use for formatted text, tables, and images.</Description>
  <IsIncluded>true</IsIncluded>
  <PartOrder>1</PartOrder>
  <FrameState>Normal</FrameState>
  <Height />
  <Width />
  <AllowRemove>true</AllowRemove>
  <AllowZoneChange>true</AllowZoneChange>
  <AllowMinimize>true</AllowMinimize>
  <AllowConnect>true</AllowConnect>
  <AllowEdit>true</AllowEdit>
  <AllowHide>true</AllowHide>
  <IsVisible>true</IsVisible>
  <DetailLink />
  <HelpLink />
  <HelpMode>Modeless</HelpMode>
  <Dir>Default</Dir>
  <PartImageSmall />
  <MissingAssembly>Cannot import this Web Part.</MissingAssembly>
  <PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>
  <IsIncludedFilter />
  <ExportControlledProperties>true</ExportControlledProperties>
  <ConnectionID>00000000-0000-0000-0000-000000000000</ConnectionID>
  <ID>g_2f31165e_fc13_4a91_b37f_b8518fe4fe0d</ID>
  <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
  <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"><![CDATA[<style type="text/css">
#orgChart {
font-size: 10px;
font-family: arial, helvetica, sans-serif;
line-height: 1.1em;
text-align: center;
}
#orgChart, #orgChart ul {
float: left;
list-style-type: none;
margin: 5px 0 0 0;
padding: 0;
text-align: center;
}
#orgChart li {
display: inline;
float: left;
margin: 10px 5px;
padding: 0;
}
#orgChart li div {
-webkit-box-shadow: rgba(0, 0, 0, 0.496094) 3px 3px 3px;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EDF7FF), to(#CDE7EE));
background-color: #EDF7FF;
border: 2px solid #CDE7EE;
border-radius: 5px;
cursor: default;
display: block;
height: 60px;
width: 150px;
margin: 0 auto;
padding: 5px;
}
</style>
</script>
]]></Content>
  <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
</WebPart>
</WebPartPages:ContentEditorWebPart>
</ZoneTemplate></WebPartPages:WebPartZone>
  &nbsp;
<SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;" id="spdatasource1">
<SelectParameters>
<asp:Parameter Name="ListID" DefaultValue="{20E455CA-1CE6-4D2C-B8B7-DF1E4C7A1336}" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="ListID" DefaultValue="{20E455CA-1CE6-4D2C-B8B7-DF1E4C7A1336}" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ListID" DefaultValue="{20E455CA-1CE6-4D2C-B8B7-DF1E4C7A1336}" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ListID" DefaultValue="{20E455CA-1CE6-4D2C-B8B7-DF1E4C7A1336}" />
</InsertParameters>
</SharePoint:SPDataSource>
<WebPartPages:DataFormWebPart runat="server" IsIncluded="True" FrameType="None" NoDefaultStyle="TRUE" ViewFlag="0" Title="Contact Details" ListName="{20E455CA-1CE6-4D2C-B8B7-DF1E4C7A1336}" Default="FALSE" DisplayName="Contact Details" __markuptype="vsattributemarkup" __WebPartId="{349C5F14-EE87-49AC-A153-DF3456B1B2AA}" id="g_349c5f14_ee87_49ac_a153_df3456b1b2aa" __AllowXSLTEditing="true" WebPart="true" Height="" Width="">
<DataSources>
<SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;" id="Contact_x0020_Details1"><SelectParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{20E455CA-1CE6-4D2C-B8B7-DF1E4C7A1336}"/></SelectParameters><DeleteParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{20E455CA-1CE6-4D2C-B8B7-DF1E4C7A1336}"/></DeleteParameters><UpdateParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{20E455CA-1CE6-4D2C-B8B7-DF1E4C7A1336}"/></UpdateParameters><InsertParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{20E455CA-1CE6-4D2C-B8B7-DF1E4C7A1336}"/></InsertParameters></SharePoint:SPDataSource>
</DataSources>
<ParameterBindings>
  <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
  <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
  <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
  <ParameterBinding Name="ListID" Location="None" DefaultValue="{20E455CA-1CE6-4D2C-B8B7-DF1E4C7A1336}"/>
  <ParameterBinding Name="TopLevel" Location="QueryString(TopLevel)" DefaultValue=""/>
  </ParameterBindings>
<datafields>@Picture,Picture;@Title,Last Name;@FirstName,First Name;@FullName,FullName;@JobTitle,Job Title;@Company,Company;@Supervisor,Supervisor;@Email,E-mail Address;@WorkPhone,Business Phone;@HomePhone,Home Phone;@CellPhone,Mobile Phone;@WorkFax,Fax Number;@WorkAddress,Address;@WorkCity,City;@WorkState,State/Province;@WorkZip,ZIP/Postal Code;@WorkCountry,Country/Region;@WebPage,Web Page;@Comments,Notes;@Team,Team;@ID,ID;@ContentType,Content Type;@Modified,Modified;@Created,Created;@Author,Created By;@Editor,Modified By;@_UIVersionString,Version;@Attachments,Attachments;@File_x0020_Type,File Type;@FileLeafRef,Name (for use in forms);@FileDirRef,Path;@FSObjType,Item Type;@_HasCopyDestinations,Has Copy Destinations;@_CopySource,Copy Source;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;</datafields>
<Xsl>
<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">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="dvt_apos">&apos;</xsl:param>
<xsl:param name="ListID">{20E455CA-1CE6-4D2C-B8B7-DF1E4C7A1336}</xsl:param>
<xsl:param name="TopLevel" ></xsl:param>

<xsl:param name="Levels" />
<xsl:param name="CurLevel">0</xsl:param>
<xsl:variable name="dvt_1_automode">0</xsl:variable>



<xsl:template match="/" 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">
<xsl:call-template name="dvt_1"/>
</xsl:template>

<xsl:template name="dvt_1">
<xsl:variable name="dvt_StyleName">BulTitl</xsl:variable>
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
<xsl:variable name="dvt_RowCount" select="count($Rows)" />
<xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0" />
<xsl:choose>
<xsl:when test="$dvt_IsEmpty">
<xsl:call-template name="dvt_1.empty" />
</xsl:when>
<xsl:otherwise><ul id="orgchart" style="width: 349px; height: 13px">
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows" />
</xsl:call-template>
</ul></xsl:otherwise>
</xsl:choose>

</xsl:template>

<xsl:template name="dvt_1.body">
<xsl:param name="Rows" />
<xsl:for-each select="$Rows[substring-before(substring-after(substring-after(@FullName, '?ID='), '&gt;'), '&lt;') = $TopLevel]">
<xsl:variable name="CurLevel" select="number(0)" />
<li>
<xsl:call-template name="contact_details">
<xsl:with-param name="Rows" select="$Rows" />
<xsl:with-param name="CurLevel" select="$CurLevel" />
<xsl:with-param name="FullName" select="substring-before(substring-after(substring-after(@FullName, '?ID='), '&gt;'), '&lt;')" />
</xsl:call-template>
<xsl:call-template name="dvt_1.rowview">
<xsl:with-param name="Rows" select="$Rows" />
<xsl:with-param name="CurLevel" select="$CurLevel" />
<xsl:with-param name="Supervisor" select="substring-before(substring-after(substring-after(@FullName, '?ID='), '&gt;'), '&lt;')" />
</xsl:call-template>
</li>
</xsl:for-each>
</xsl:template>

<xsl:template name="dvt_1.rowview">
<xsl:param name="Rows" />
<xsl:param name="CurLevel" />
<xsl:param name="Supervisor" />
<xsl:variable name="LevelTest" select="number($CurLevel + 1)" />
<xsl:if test="($LevelTest &lt;= number($Levels))">
<xsl:if test="$Rows[substring-before(substring-after(substring-after(@Supervisor, '?ID='), '&gt;'), '&lt;') = $Supervisor]">
<ul>
<xsl:for-each select="$Rows[substring-before(substring-after(substring-after(@Supervisor, '?ID='), '&gt;'), '&lt;') = $Supervisor]">
<li>
<xsl:call-template name="contact_details">
<xsl:with-param name="Rows" select="$Rows" />
<xsl:with-param name="FullName" select="substring-before(substring-after(substring-after(@FullName, '?ID='), '&gt;'), '&lt;')" />
</xsl:call-template>
<xsl:call-template name="dvt_1.rowview">
<xsl:with-param name="Rows" select="$Rows" />
<xsl:with-param name="CurLevel" select="$LevelTest" />
<xsl:with-param name="Supervisor" select="substring-before(substring-after(substring-after(@FullName, '?ID='), '&gt;'), '&lt;')" />
</xsl:call-template>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:if>
</xsl:template>

<xsl:template name="contact_details">
<xsl:param name="Rows" />
<xsl:param name="CurLevel" />
<xsl:param name="FullName" />
<xsl:for-each select="$Rows[substring-before(substring-after(substring-after(@FullName, '?ID='), '&gt;'), '&lt;') = $FullName]">
<div>
<xsl:value-of select="@FullName" disable-output-escaping="yes" /><br />
<xsl:value-of select="substring-before(substring-after(substring-after(@JobTitle, '?ID='), '&gt;'), '&lt;')" /><br />
<xsl:value-of select="substring-before(substring-after(substring-after(@WorkPhone, '?ID='), '&gt;'), '&lt;')" /><br />
<a href="mailto:{substring-before(substring-after(substring-after(@Email, '?ID='), '&gt;'), '&lt;')}"><xsl:value-of select="substring-before(substring-after(substring-after(@Email, '?ID='), '&gt;'), '&lt;')" /></a>
</div>
</xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.empty">
<xsl:variable name="dvt_ViewEmptyText">There are no items to show in this view.</xsl:variable>
<table border="0" width="100%">
<tr>
<td class="ms-vb">
<xsl:value-of select="$dvt_ViewEmptyText" />
</td>
</tr>
</table>
</xsl:template>

</xsl:stylesheet>
</Xsl>
</WebPartPages:DataFormWebPart>
  </td>
  <td style="height: 499px"></td>
  <td valign="top" width="30%" style="height: 499px">
  &nbsp;
  </td>
  <td style="height: 499px"></td>
 </tr>
</table>
</td>
 </tr>
</table>
</asp:Content>

1 comment:

  1. 1. Remove the scripts from the page for now. Without them does the nested list look correct or does it still output each person 8 times?

    2. The XSLT looks OK to me, but I have no way to test it right now so I can't be sure.

    3. Can you post the rendered HTML for the page too?

    4. Can you post the raw output of the @FullName and @Supervisor columns without any substring changes? I'm guessing your server is not using english, and those values might be output differently, which would require different Xpath.

    Thanks!

    ReplyDelete