Geeks With Blogs

News

qrcode

Lance Robinson

Create Your Badge

Lance Robinson is a software engineer in Durham, Chapel Hill, Raleigh, and surrounding areas. More about Lance.

 Subscribe


Lance's TextBox » About Me » My Resume »Twitter
 

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!

 shipmenttracker
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 RSSBus.com 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”.

 
 
 
 
<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 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: GeeksWithBlogs.net