Solved

cfscript and cfc not working

Posted on 2014-11-11
10
105 Views
Last Modified: 2014-11-11
I have a line

variables.usps = New usps(isProduction=true, isSecure=false, uspsUserID=variables.uspsUserID);

variables.RateV4 = variables.usps.RateV4(
	Service = 'FIRST CLASS',
	FirstClassMailType = 'PARCEL',
	ZipOrigination = '99212',
	ZipDestination = '22193',
	SIZE = 'REGULAR',
	Pounds = '0',
	Ounces = '3.5'

Open in new window


that works just fine in development (which is CF9) but when I load this to live it doesn't work (which is CF8).    Why doesn't that work on CF8??
0
Comment
Question by:digitalwise
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 40435889
Is it throwing an error, if so on what line - and what's the error message?

My first guess would be that the "new" keyword didn't exist in CF8. So you need to replace it with createObject and a call to init()

EDIT: I don't know if CF8 supports chaining, so I broke this out into 2 separate calls:

   
   
     // not tested
     variables.usps = createObject("component", "path.to.uspsComponent");
     variables.usps = variables.usps.init(isProduction=true, isSecure=false, uspsUserID=variables.uspsUserID);

Open in new window

0
 
LVL 6

Expert Comment

by:rjohnsonjr
ID: 40435891
Any error messages you can share?
0
 

Author Closing Comment

by:digitalwise
ID: 40435911
As usual - thanks for the help!   Wandering between CF10 and this old CF8 site is a huge pain!    Completely missed it.   Now the problem is the CFC was written for CF9 so I have to fix that stuff too!
0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
LVL 52

Expert Comment

by:_agx_
ID: 40435925
I hear you! I really wish they would make older versions available for developers, so they don't have to depend on the "publish-it-and-hope-it-doesn't-break" method ;-)
0
 
LVL 6

Expert Comment

by:rjohnsonjr
ID: 40435953
Here is an unofficial repo containing all the old cf installer downloads.

http://www.gpickin.com/cfrepo/
0
 

Author Comment

by:digitalwise
ID: 40435960
So I am working through this mess and getting the error:  Variable SETURLTEST is undefined.

<cffunction name="init" access="public" returntype="USPS" output="false" hint="Initializes the USPS CFC">
		<cfargument name="isProduction" type="boolean" required="false" default="#getIsProduction()#">
		<cfargument name="isSecure" type="boolean" required="false" default="#getIsSecure()#">
		<cfargument name="uspsUserID" type="string" required="false" default="#getUspsUserID()#">
		<cfscript>
			// set constants (CF9 fix)
			setURLTEST("http://testing.shippingapis.com/ShippingAPITest.dll");
			setURLTESTSECURE("https://secure.shippingapis.com/ShippingAPITest.dll");
			setURLPROD("http://production.shippingapis.com/ShippingAPI.dll");
			setURLPRODSECURE("https://secure.shippingapis.com/ShippingAPI.dll");

			// set production and secure flags
			setIsProduction(arguments.isProduction);
			setIsSecure(arguments.isSecure);
			setUspsUserID(arguments.uspsUserID);

			// configure url based on flags
			if(getIsProduction()){
				if(getIsSecure()){
					setUrl(getURLPRODSECURE());
				}
				else{
					setUrl(getURLPROD());
				}
			}
			else{
				if(getIsSecure()){
					setUrl(getURLTESTSECURE());
				}
				else{
					setUrl(getURLTEST());
				}
			}

			return this;
		</cfscript>
	</cffunction>

Open in new window

0
 
LVL 52

Expert Comment

by:_agx_
ID: 40435975
Which line is throwing the error? I don't see anything that looks CF9 specific, so I'm guessing the problem is in one of the functions.  Any chance this CFC is public btw - so I could look a the whole thing?
0
 

Author Comment

by:digitalwise
ID: 40435979
0
 
LVL 52

Expert Comment

by:_agx_
ID: 40436080
<cfproperty name="isProduction" type="boolean">
<cfproperty name="isSecure" type="boolean">
<cfproperty name="uspsUserID" type="string">
<cfproperty name="url" type="string">
<cfproperty name="URLTEST" type="string">
<cfproperty name="URLTESTSECURE" type="string">
<cfproperty name="URLPROD" type="string">
<cfproperty name="URLPRODSECURE" type="string">

Open in new window


Hm... I wonder if it's cfproperty stuff.  I know in later versions it creates the setters/getters automatically. I don't remember how it behaved in CF8.

Edit: Yeah, that's the problem. You'll have to create the getters/setters manually.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 40436094
Edit: Yeah, that's the problem. In CF9+ cfproperty creates the getter/setter's automatically. Not so much in CF8 :/. You have to create those methods manually.

<cffunction name="setURLTEST" access="public" returntype="void">
    <cfargument name="value" type="String" required="true">
    <cfset variables.URLTEST = arguments.value />
</cffunction>
...

Open in new window

0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

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 …
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

740 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