Geeks With Blogs

Lance's TextBox

This post is the sixth in a series of postings, containing examples of SharePoint WebParts that anybody can build all by themselves.  To read all posts in this series, or to get started with the RSSBus WebPart, go here.

#6 – Shipment Tracking Web Part!

I’ve been holding on to this one for a while.  Until recently it was just a FedEx shipment tracker, but now the UPS and USPS Connectors have been published at so this can be what I wanted it to be.  This sample will allow the user to input a tracking number for UPS, USPS, or Fedex, and then display tracking events for that shipment in an easy to read table.

Step one is to make sure you have the RSSBus Web Part installed.  See here for instructions.

Step two, make sure you have the UPS, USPS, and/or FedEx Connectors installed.  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 three, add the RSSBus WebPart to your page and paste the following template into its source editor, and click “Apply”.

<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" />

<!-- a form to accept tracking number and shipping company -->
<div id="trackinginput">
<table cellspacing="5px">
<td>Tracking Number:</td>
<input type="text" name="trackingnumber" value="" size="25"/>
<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 align="right">
<input type="submit" value="Track" />

<!-- 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="" />
<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 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="" />
<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 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="" />
<rsb:set attr="global.operation" value="fedexTrack" />
<rsb:set attr="global.input" value="fedex" />

<rsb:call op="[[global.operation]]" in="[[global.input]]">
<table width="100%">
<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>
<td>[[scandate]] [[scantime]]</td>
<td>[[scancity]], [[scanstate]] [[scancountry]]</td>

Step four is to specify your account credentials.  If you’ve 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 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 if you want, or leave it as is.

See all posts in this series:  10 DIY SharePoint Web Parts.
Browse RSSBus Connectors.
Basic RSSBus Scripting Cheat Sheet.


Technorati Tags: , , , , ,
Posted on Tuesday, September 22, 2009 4:02 AM | Back to top

Comments on this post: 10 DIY SharePoint Web Parts #6

# re: 10 DIY SharePoint Web Parts #6
Requesting Gravatar...

Usps package Tracking
Usps Tracking package
usps tracking mobile
usps international tracking
track ups
usps tracking number
usps phone number
usps customer service
usps contact
usps tracking phone number
Left by usps track on Feb 06, 2017 1:01 AM

Your comment:
 (will show your gravatar)

Copyright © Lance Robinson | Powered by: