A SharePoint Web Part for Shipment Tracking

This sample allows the user to input a tracking number for UPS, USPS, or Fedex and then display tracking events in an easy-to-read table.

  • Step 1: Ensure the RSSBus Web Part is installed.
  • Step 2: Install the UPS, USPS, and/or FedEx Connectors. You don�t need them all if you don�t want them all, you only need the ones you want to be able to track packages for. Make sure that you have service credentials for the shipping companies you want to use. UPS, USPS, and Fedex all require user/password/etc in order to reach their package tracking web services.
  • Step 3: Add the RSSBus WebPart to your page and paste the following template into its source editor, and click "Apply".
<rsb:info>
   <input name="ups-accesskey" required="true" />
   <input name="ups-accountnumber" required="true" />
   <input name="ups-user" required="true" />
   <input name="ups-password" required="true" />
   <input name="usps-user" required="true" />
   <input name="usps-password" required="true" />
   <input name="fedex-accountnumber" required="true" />
   <input name="fedex-meternumber" required="true" />
   <input name="fedex-developerkey" required="true" />
   <input name="fedex-password" required="true" />
</rsb:info>

<!-- a form to accept tracking number and shipping company --> 
<div id="trackinginput">
 <table cellspacing="5px">
 <tr>
   <td>Tracking Number:</td>
   <td>
     <input type="text" name="trackingnumber" value="" size="25"/>
   </td>
   <td align="right" colspan="2">
     <input type="radio" name="shipper" value="UPS">UPS
     <input type="radio" name="shipper" value="USPS">USPS
     <input type="radio" name="shipper" value="FedEx" checked>FedEx
   </td>
   <td align="right">
     <input type="submit" value="Track" />
   </td>
 </tr>
 </table>                              
</div>

<!-- when the form is posted, display a table of ship events --> 
<rsb:check attr="_request.form:trackingnumber">
  <div style="height:250;overflow:auto">
    <rsb:select value="[_request.form:shipper | tolower]">
     <rsb:case match="exact" value="ups">
      <rsb:import lib="RSSBus.UpsOps" />
      <rsb:set attr="ups.user" value="[ups-user]" />
      <rsb:set attr="ups.password" value="[ups-password]" />
      <rsb:set attr="ups.accesskey" value="[ups-accesskey]" />
      <rsb:set attr="ups.accountnumber" value="[ups-accountnumber]" />
      <rsb:set attr="ups.url" value="https://wwwcie.ups.com/ups.app/xml/Track" />          
      <rsb:set attr="ups.trackingid" value="[_request.form:trackingnumber]" />                 
      <rsb:set attr="global.operation" value="upsTrack" />
      <rsb:set attr="global.input" value="ups" />
    </rsb:case>
    <rsb:case match="exact" value="usps">
     <rsb:import lib="RSSBus.UspsOps" />
     <rsb:set attr="usps.user" value="[usps-user]" />
     <rsb:set attr="usps.password" value="[usps-password]" />
     <rsb:set attr="usps.url" value="http://production.shippingapis.com/ShippingAPI.dll" />           
     <rsb:set attr="usps.trackingid" value="[_request.form:trackingnumber]" />
     <rsb:set attr="global.operation" value="uspsTrack" />
     <rsb:set attr="global.input" value="usps" />    
    </rsb:case>
    <rsb:case match="exact" value="fedex">
     <rsb:import lib="RSSBus.FedexOps" />
     <rsb:set attr="fedex.password" value="[fedex-password]" />
     <rsb:set attr="fedex.accountnumber" value="[fedex-accountnumber]" />
     <rsb:set attr="fedex.meternumber" value="[fedex-meternumber]" />
     <rsb:set attr="fedex.developerkey" value="[fedex-developerkey]" />
     <rsb:set attr="fedex.trackingid" value="[_request.form:trackingnumber]" />
     <rsb:set attr="fedex.trackingidtype" value="TRACKINGNUMBERORDOORTAG" />
     <rsb:set attr="fedex.url" value="https://gatewaybeta.fedex.com:443/xml" />
     <rsb:set attr="global.operation" value="fedexTrack" />
     <rsb:set attr="global.input" value="fedex" />    
    </rsb:case>    
  </rsb:select>

  <rsb:call op="[global.operation]" in="[global.input]">
   <rsb:first>
     <table width="100%">
       <tr>
        <th style="background-color:LightGrey; white-space:nowrap">Status</th>                             
        <th style="background-color:LightGrey; white-space:nowrap">Date/Time</th>                       
        <th style="background-color:LightGrey; white-space:nowrap">Location</th>                           
      </tr>
    </rsb:first>
       <tr>
        <td>[scandesc]</td>
        <td>[scandate] [scantime]</td>
        <td>[scancity], [scanstate] [scancountry]</td>
      <tr>
   <rsb:last>
     </table>
   </rsb:last>
 </rsb:call>
</div>
</rsb:check>
  • Step 4: Specify your account credentials. If you clicked "Apply" in the source editor of the Web Part, you should now see a new property appear in the properties editor of the Web Part in your browser. Under "Web Part Inputs", you'll see "ups-accesskey", "ups-accountnumber", and several other credential inputs. These inputs will need to be populated with the values corresponding to your web service account credentials obtained from UPS, USPS, and/or FedEx. If you�re not using one or more of these shipping companies, just insert a dummy value or modify the template so that input is not required.

After you have set these inputs appropriately, click "Apply" in the properties window and the page will reload. Enter a tracking number, select the shipping company, and click "Track". The tracking events will be displayed inside the web part!

As always, you can customize the HTML in the template, or leave it as is.