Solved

Displaying Shipment Tracking Information in Coldfusion

Posted on 2014-11-11
7
133 Views
Last Modified: 2014-11-15
Order HistoryFedEx Tracking Information
Hi,
  I have a CFM page where I display order information along with tracking number. When I click "TrackingNo" field, I would like to display tracking information provided by FedEx website based on the tracking number in the Order Listing Form/CFGRID.
  Below is my actual CFM code and FedEx URL.
 How can I modify current code to display tracking information from FedEx website when the user clicks "TrackingNo" from the CFGRID?
 
https://www.fedex.com/fedextrack/WTRK/index.html?action=track&action=track&tracknumbers=123456789&fdx=1490
 
<cfform action = "#CGI.SCRIPT_NAME#">
    <cfgrid name = "FirstGrid" width = "900"
            query = "GetOrderHistory" colheaderbold="Yes"
            font = "Tahoma" rowHeaders = "No"
            selectColor = "Red" selectMode = "Edit" format="HTML" > 
        <cfgridcolumn name="StoreID" header="StoreID" width=70>
        <cfgridcolumn name = "TrackingNo" header = "TrackingNo" Select="No" width="150" textcolor="blue" bold="Yes"> href="ShippingInfo.cfm" hrefkey="ID">
        <cfgridcolumn name = "Location" header = "Location" Select="No" width="200" bold="Yes">
        <cfgridcolumn name="City" header="City" width=100>
    </cfgrid>
    <br>
    <cfinput type="submit" name="gridEntered">
</cfform>
0
Comment
Question by:sglee
  • 3
  • 2
  • 2
7 Comments
 
LVL 25

Expert Comment

by:dgrafx
ID: 40437663
Do you mean you want to display a Fedex page like shown above on your website?
Investigate their webservices here: http://www.fedex.com/us/web-services/
0
 

Author Comment

by:sglee
ID: 40437697
@dgrafx
my goal, when the user clicks the link(FedEx tracking#), is to go to FedEx website and display what they provide.
It is just like you and I go to FedEx.com and enter the tracking number to display shipping status.
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 40437717
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 40438904
I don't use cfgrid much - but AFAIK, there's no simple way to make that happen. Honestly the CF ajax stuff is a bit of a pain to extend and workarounds for CF8 won't necessarily work in 9 or 10. Anyway, the closest I could get to "simple" is this (tested w/CF10).

Note: MUST set appendKey="false" or the javascript won't work

<script type="text/javascript">
	function displayFedexPage() {
                // get reference to grid
		var grid = ColdFusion.Grid.getGridObject('FirstGrid');
               // if something is selected
		if (grid.getSelectionModel().hasSelection()) {
                    // get selected row
		   var row = grid.getSelectionModel().getSelected();
                   // get value in tracking number value
		   var trackingNo = row.get('TRACKINGNO');
                   // go to fedex tracking page
		   window.location.href = "http://www.fedex.com/Tracking?action=track&tracknumbers="+ trackingNo;
		}
	}
</script>
<cfform action = "#CGI.SCRIPT_NAME#">
    <cfgrid name = "FirstGrid" width = "900"
            query = "GetOrderHistory" colheaderbold="Yes"
            font = "Tahoma" rowHeaders = "No"
            selectColor = "Red" selectMode = "Edit" format="HTML"
	    appendKey="false">
        <cfgridcolumn name="StoreID" header="StoreID" width=70>
        <cfgridcolumn name = "TrackingNo" header = "TrackingNo" 
			href="javascript:displayFedexPage()"
			hrefKey="TrackingNo"
			Select="No" width="150" textcolor="blue" bold="Yes"> 
        <cfgridcolumn name = "Location" header = "Location" Select="No" width="200" bold="Yes">
        <cfgridcolumn name="City" header="City" width=100>
    </cfgrid>
    <br>
    <cfinput type="submit" name="gridEntered">
</cfform> 

Open in new window

0
 

Author Comment

by:sglee
ID: 40444495
@agx_
I just tried it and it worked great!  That is exactly what I wanted to do.
Thank you very much!
0
 
LVL 52

Expert Comment

by:_agx_
ID: 40444593
Glad it helped.

( I'd thought using href and hrefKey would do it, but CF doesn't allow you to set the URL parameter name, so that doesn't quite cut it.  This is such a common need. You'd think it would be simpler ;-)
0
 

Author Comment

by:sglee
ID: 40444711
I agree and again thank you.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question