Sharing SharePoint

Always a rookie in the SharePoint World

Customizing RSS Viewer to display Weather.com forecast

Posted by Jessica Wang on March 25, 2008

Step 1:  Register for Free at Weather.com to get your Partner ID and License Key

Step 2: Enter http://xoap.weather.com/weather/local/ASXX0075?cc=*&dayf=6&par=PartnerID&prod=xoap&unit=m&key=LicenseKey into RSS Feed URL

Step 3: Edit the XSL

<?xml version=”1.0″ encoding=”ISO-8859-1″ ?><xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”><xsl:output method=”html” indent=”yes” encoding=”iso-8859-1″ /><xsl:template match=”/weather”>

<xsl:variable name=”med-img-dir”>WeatherIcons/60×59</xsl:variable>

<!–Purpose: Weather Webpart, information from Weather.com–>

         <xsl:variable name=”day” select=”dayf/day[@d]”></xsl:variable>

        <xsl:for-each select=”$day”>

 <!– Current Weather Conditions –>

<table width=”100%”>

                <tr>

                                <!–Image–>

                                <td style=”width: 70px;font-size: 11px” rowspan=”3″>

                                <xsl:variable name=”img-ext”>png</xsl:variable>

                                <xsl:variable name=”iconnumber” select=”part[@p=’d’]/icon” />

                                <img src=”{$med-img-dir}/{$iconnumber}.{$img-ext}” mce_src=”{$med-img-dir}/{$iconnumber}.{$img-ext}” alt=”{$iconnumber}.{$img-ext}” width=”40″ height=”42″ />

                                </td>

                                <!–Day and Date–>

                                <td style=”font-size: 11px; font-weight: bold; padding:0px 0px 0px 0px” colspan=”2″>

                                                                <xsl:value-of select=”./@dt” />,

                                                                <xsl:value-of select=”./@t” />

                                                                </td>

                </tr>

                <tr>

                                <td style=”font-size: 11px; padding:0px 0px 0px 0px” colspan=”2″>                                        

                                                                <xsl:value-of select=”part[@p=’d’]/t”/>

                                                                </td>

                </tr>

                <tr>

                <!–Temperature–>

                                                                <td style=”font-size: 11px; padding:0px 0px 0px 0px”>Min:

                                                                <xsl:value-of select=”low”></xsl:value-of>C </td>

                                                                <td style=”font-size: 11px; padding:0px 0px 0px 0px” >Max:

                                                                <xsl:value-of select=”hi”></xsl:value-of>C </td>

                </tr>

</table>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

Advertisements

Posted in WebParts, XSLT | Leave a Comment »

Get User Collection from a Sharepoint Group

Posted by Jessica Wang on March 25, 2008

I have been working on getting a drop down list in Infopath to be populated with users of a Sharepoint Group. You can’t connect directly to the drop drop list, so you will need to create 2 data sources, 1 to the web service and another xml file with dummy data which will be replace be information from the web service.

1. Create a data connection to the web service using the data connection wizard.

<http://servername/_vti_bin/UserGroup.asmx?WSDL>

Data Connection

Click next and select GetUserCollectionFromGroup

Enter Sample data, which is the name of the group which you wish to get data from.

2. You will need dummy data to be connected to the drop down list first. There are 2 dummy users in the xml, it tells infopath that it is repeating.

DummyData.xml

<?xml version=”1.0″ encoding=”utf-8″ ?>

 <dfs:myFields xmlns:dfs=”http://schemas.microsoft.com/office/infopath/2003/dataFormSolution&#8221; xmlns:s0=”http://schemas.microsoft.com/sharepoint/soap/directory/&#8221; xmlns:my=”http://schemas.microsoft.com/office/infopath/2003/myXSD/2004-03-16T06-17-54&#8243; xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema”&gt;    <dfs:queryFields>        <s0:GetUserCollectionFromGroup>        </s0:GetUserCollectionFromGroup>    </dfs:queryFields>    <dfs:dataFields>        <GetUserCollectionFromGroupResponse xmlns=”http://schemas.microsoft.com/sharepoint/soap/directory/”&gt;            <GetUserCollectionFromGroupResult>                <GetUserCollectionFromGroup>                    <Users>                        <User ID=”1″ Sid=”S-1-5-21-3593225548-2099380924-3969701235-500″ Name=”User1″ LoginName=”login1″ Email=”user1@users.com” Notes=”” IsSiteAdmin=”False” IsDomainGroup=”False”/>                        <User ID=”2″ Sid=”S-1-5-21-3593225548-2099380924-3969701235-1145″ Name=”User2″ LoginName=”login2″ Email=”user2@users.com” Notes=”” IsSiteAdmin=”False” IsDomainGroup=”False”/>                    </Users>                </GetUserCollectionFromGroup>            </GetUserCollectionFromGroupResult>        </GetUserCollectionFromGroupResponse>    </dfs:dataFields></dfs:myFields>

Save the dummydata.xml and connect it via the Data Connection Wizard as well.

3. Link the drop down list to the dummydata.xml

dropdownlist.png

4. You will need to go to the loading event of the infopath form, which you can get to by going to Tools>Programming>Loading Event

It will open up Visual studio. Within the Loading Event, you will need the following piece of code.

public void FormEvents_Loading(object sender, LoadingEventArgs e)

{ 

//Dummy Data

//get an XPathNavigator to our webservice method                                                XPathNavigator dutyManagerDummy = this.DataSources[“DutyManagerListDummyData”].CreateNavigator();

//create the XmlNamespaceManager that will allow us to navigate the xml
XmlNamespaceManager
umanager = new XmlNamespaceManager(dutyManagerDummy.NameTable);

umanager.AddNamespace(“dfs”, http://schemas.microsoft.com/office/infopath/2003/dataFormSolution);

umanager.AddNamespace(“tns”, http://schemas.microsoft.com/sharepoint/soap/directory/);

//get the node that contains all the users from dummy data
XPathNavigator
DutyManagerListDummyDataName = dutyManagerDummy.SelectSingleNode(“/dfs:myFields/dfs:dataFields/tns:GetUserCollectionFromGroupResponse/tns:GetUserCollectionFromGroupResult/tns:GetUserCollectionFromGroup/tns:Users”, umanager);

//Actual Data

//get an XPathNavigator to our webservice method                                                 XPathNavigator dutyManager = this.DataSources[“GetUserCollectionFromGroup”].CreateNavigator();

//create the XmlNamespaceManager that will allow us to navigate the xml
XmlNamespaceManager
dmanager = new XmlNamespaceManager(dutyManager.NameTable);

dmanager.AddNamespace(“dfs”, http://schemas.microsoft.com/office/infopath/2003/dataFormSolution);

dmanager.AddNamespace(“tns”, http://schemas.microsoft.com/sharepoint/soap/directory/);

//get the node that contains all the users from the call to the web service
XPathNavigator
dusers = dutyManager.SelectSingleNode(“/dfs:myFields/dfs:dataFields/tns:GetUserCollectionFromGroupResponse/tns:GetUserCollectionFromGroupResult/tns:GetUserCollectionFromGroup/tns:Users”, umanager);

                         try{               

                             //replace the dummy information from the information from the web service
                             DutyManagerListDummyDataName.ReplaceSelf(dusers);
           

                            }           

                         catch(NullReferenceException ee){}

}

Run the preview and you should see the actual data instead of the dummy information.

Posted in Infopath | 9 Comments »

Customizing Content Query Webpart

Posted by Jessica Wang on March 3, 2008

  

Firstly, Heather Solomon has an excellent article on it.

Part 1: Export Content Query Web part

Open it up and search for CommonViewFields

Add in Fields that you want; you will need to use the internal name and the type of data.

A good tool is Sharepoint Explorer for WSS 

<property name=”CommonViewFields” type=”string”>InternalName, DateField</property>

Example: Calendar Properties 

<property name=”CommonViewFields” type=”string”>EventDate,DateTime; Description,Note; Location,Text; Property_x0020_Unit,Choice</property>

Save the Web Part and Import it back 

Part 2: Locate ItemStyle.xsl under XSL Style Sheet

Create your own custom Item Style 

<xsl:template name=”CustomStyle” match=”Row[@Style=’CustomStyle’]” mode=”itemstyle”>  <xsl:variable name=”SafeImageUrl”>
            <xsl:call-template name=”OuterTemplate.GetSafeStaticUrl”>
                <xsl:with-param name=”UrlColumnName” select=”‘ImageUrl'”/>
            </xsl:call-template>
        </xsl:variable>
  <xsl:variable name=”SafeLinkUrl”>
            <xsl:call-template name=”OuterTemplate.GetSafeLink”>
                <xsl:with-param name=”UrlColumnName” select=”‘LinkUrl'”/>
            </xsl:call-template>
        </xsl:variable>
  <xsl:variable name=”DisplayTitle”>
            <xsl:call-template name=”OuterTemplate.GetTitle”>
                <xsl:with-param name=”Title” select=”@Title”/>
                <xsl:with-param name=”UrlColumnName” select=”‘LinkUrl'”/>
            </xsl:call-template>
        </xsl:variable>
  <xsl:variable name=”LinkTarget”>
            <xsl:if test=”@OpenInNewWindow = ‘True'” >_blank</xsl:if>
        </xsl:variable>
  <table>
   <tr>
    <td style=”width: 200px”>          
  <xsl:value-of select=”ddwrt:FormatDate(string(@EventDate),3081, 3)”/></td>
    <td valign=”top” rowspan=”3″>|</td>    <td class=”linkitem” style=”width: 200px”>      
    <xsl:call-template name=”OuterTemplate.CallPresenceStatusIconTemplate”/>
                <a href=”{$SafeLinkUrl}” mce_href=”{$SafeLinkUrl}” target=”{$LinkTarget}” title=”mailto:%7B@LinkToolTip}”>
                    <xsl:value-of select=”$DisplayTitle”/>
                </a>
        </td>
   </tr>
   <tr>
    <td rowspan=”3″ align=”left”>    
    <xsl:value-of select=”ddwrt:FormatDate(string(@EventDate),3081, 4)”/></td>
    <td>Location: <xsl:value-of select=”@Location”/></td>
   </tr>
   <tr>
    <td >PropertyUnit: <xsl:value-of select=”@Property_x005F_x0020_Unit “/>
</td>
   </tr>
   <tr>
    <td> xsl:value-of select=”@Description” disable-output-escaping=”yes”/></td>
   </tr>
    </table>To see what fields are being passed in<xsl:for-each select=”@*”>
    P:<xsl:value-of select=”name()” />
</xsl:for-each>
 </xsl:template>

If you want to format the Date Time using ddwrt, remember to add   xmlns:ddwrt=”http://schemas.microsoft.com/WebParts/v2/DataView/runtime” within the <xsl:stylesheet> tag.
  

Posted in WebParts | Leave a Comment »