CFFUNCTION returntype error

"The value returned from the addRequirement function is not
of type query" is what I get when I execute the below function.
This works fine in 7, but in 8 I get that error. Any ideas?
<CFFUNCTION NAME="addItem" output="false"
returntype="query">
<CFARGUMENT NAME="userid" TYPE="numeric"
REQUIRED="true">
<CFARGUMENT NAME="title" TYPE="string"
REQUIRED="true">
<cfset var addRequirement = "">
<CFQUERY NAME="addItem" datasource="#variables.dsn#">
INSERT INTO test(userID,title)
VALUES (#ARGUMENTS.userID#,'#arguments.title#')
</CFQUERY>
<cfreturn addItem>
</CFFUNCTION>

In addition to the insert not returning a result set, you
have your var declared as 'addRequirement'
but your query name and return value are 'addItem'
If it were me, I'd set the return type to boolean, then set a
var result = 'FALSE'. Wrap the insert query in a CFTRY and if it's
sucessful, set result = 'TRUE' and then return result

Similar Messages

  • Cffunction returntype question

    I've got a function (below) in a CFC that executes a stored
    procedure. The procedure has 2 input parameters and a single output
    parameter. I want to cfoutput the value of the output parameter in
    the procedure. The procedure does it's job in CF if I don't return
    the output parameter. I keep having problems with the
    returnvariable type. I've output returntypes of query in the past
    without any problem, but never a single calculated value. The value
    being output by the procedure is a long integer.
    <!--- FUNCTION --->
    <cffunction name="myFunctTest" hint="ProcedureTest"
    returntype="??????">
    <cftry>
    <cfstoredproc procedure="myProc" username='#this.user#'
    password='#this.pass#' datasource='#this.dSource#'>
    <cfprocparam type="Out" cfsqltype="cf_sql_integer"
    variable="OutputID"><!--- Output variable I want to return
    --->
    <cfprocparam type="In" cfsqltype="CF_SQL_INTEGER"
    value='#this.par1#' dbvarname="myPar1">
    <cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR"
    value='#this.par2#'dbvarname="myPar2">
    </cfstoredproc>
    <cfcatch type="any">
    <cfreturn "Error in Function...">
    </cfcatch>
    </cftry>
    <cfreturn ??????>
    </cffunction>
    <!--- FUNCTION CALL --->
    <cfinvoke component="cfc.myCFC" method="myFunctTest"
    returnvariable="??????">
    <cfinvokeargument name="user" value="#myUser#">
    <cfinvokeargument name="pass" value="#MyPass#">
    <cfinvokeargument name="dSource" value="#myDSource#">
    <cfinvokeargument name="par1" value="#Form.MyPar1#">
    <cfinvokeargument name="par2" value="#Form.MyPar2#">
    </cfinvoke>
    Thanks in advance
    Roy.

    Combine,
    Are your stored procedure parameters defined in the same
    order you are using them in your CFSTOREDPROC tag? Bear in mind
    that the dbvarname attribute is ignored in CF6+.

  • Cffunction valitation error

    Hi,
    I have a form where I  fill a customer-no. into an input field and get the customer name using databinding.
    This works fine, but when I put non-numeric values into customer-no I get following error:
    Error invoking CFC customer.cfc : The CUST_ID argument passed to the getcustomer function is not of type numeric. [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]
    The message is correct, but how can I avoid to run the getcustomer function when the value is not numeric?
    Here is my code:
    The form:
    <cfinput type="text" name="customer_no" style="width:140;background-color:yellow" maxlength="10"  validate="integer" validateat="onblur"   message="Customer No. format is integer">
    <cfinput type="text" name="customer_name" style="width:170" maxlength="200" bind="cfc:customer.getcustomer({customer_no})" readonly="yes">
    customer.cfc:
    <cfcomponent >
    <cffunction name="getcustomer" access="remote" returntype="string" output="yes"  >
        <cfargument name="cust_id"   type="numeric"  required="true" >
                     <cfset  r_customer = "">
             <cfquery name = "select_customer" dataSource = "x">
            SELECT name
            FROM customer
            WHERE id =  <cfqueryparam   cfsqltype="cf_sql_numeric" value="#arguments.cust_id#" >
            </cfquery>
    <cfreturn r_customer>
    </cffunction>
    </cfcomponent>

    biene22 wrote:
    The message is correct, but how can I avoid to run the getcustomer function when the value is not numeric?
    That is a trick question! The attribute bind="cfc:customer.getcustomer({customer_no})" implies that the function will run automatically, whether or not customer_no is numeric.

  • Cffunction returntype

    If I have a cffunction within a cfc that simply does an
    update on the DB should I use returntype="void"?
    How about not even specifying the returntype?
    Thanks!

    Tend to agree here - if you havea requirement for strong
    typing you probably
    shouldn't be using coldfusion. These days, it seems we either
    want to work
    with dynamic languages or more tradiotonal "compiled"
    languages. And the
    choice for dynamic languages is usually made on "the need for
    speed" at
    development time - strong typing would seem to run contrary
    to this idea.
    Btw - even in compiled languages (java, c#) you can still get
    type errors at
    runtime - compliler cannot catch them all unfortunately. (eg;
    cast errors,
    null reference errors)
    "Hal B. Helms" <[email protected]> wrote in
    message
    news:f72sfs$los$[email protected]..
    > The question is one of whether ANY typing should be
    used. The goal of
    > typing
    > variables is "type safety" -- the assurance that no data
    type mismatches
    > can
    > occur. In a strongly-typed language such as Java or C#,
    this happens at
    > compile
    > time and it's very helpful.
    >
    > In a weakly-typed language such as ColdFusion or Ruby,
    the only time
    > type-checking can be done is at run time. This is much,
    much less helpful.
    > My
    > own personal opinion is to omit all typing of variables.
    There's so little
    > to
    > gain and quite a cost involved (beyond the finger
    typing).
    >

  • Why setting var in CFFUNCTION causes error

    As far as my knowledge goes, the BEST practise when setting
    local variable inside a CFFUNCTION is to use the word "var" in
    front of the variable name, for example: <CFSET var
    myVariable="whatever">
    I'm doing it now and all I get is an error message saying:
    Error invoking CFC name_of_cfc:local variable myVariable on
    line 60 must be grouped at the top of the function body!
    I'm using CF8 and I need to use cfswitch within the
    cffunction, so when I do <cfcase value="SomeValue"><cfset
    var myVariable="TheValue"></cfcase> etc I got that error.
    When I tested with just CFSET var MyVariable="TheVariable"
    with no cfswitch/cfcase I still get that error
    when I took out the word "var" from cfset, I have no error, I
    put these variables directly after my cfarguments. Does anyone know
    why this is happening to me?
    I thought if I don't use the "var" word for my variable set
    within cffunction there will be possibilities when later on setting
    up another variables outside this function and if the name happen
    to be the same, will override each other and causing disaster to my
    application.
    Please help!!

    mega_L wrote:
    > As far as my knowledge goes, the BEST practise when
    setting local variable
    > inside a CFFUNCTION is to use the word "var" in front of
    the variable name, for
    > example: <CFSET var myVariable="whatever">
    Yes, this is the best practice to make the variable local to
    the
    function. But you only need to use the var keyword once when
    you define
    the variable. And you must define the local variables with
    the var
    keyword at the very beginning of the function body. The only
    content
    allowed before this happens are the argument definitions,
    i.e. the
    <cfargument ...> tags.
    If you have a variable that you don't need to use, you just
    need to
    define it with a default and|or dummy value in the beginning
    of the
    function. Then you can set it's value appropriately later in
    the
    function when it is required. This is often done with query
    tag return
    variables.
    I.E.
    <cffunction name="myQryFunction"...>
    <cfargument name="someArgument"...>
    <cfset var localQry = "">
    <cfquery name="localQry"...>
    SQL
    </cfquery>
    <cfreturn localQery>
    </cffunction>
    Because of this necessity to define all local variables at
    the beginning
    of the function, a lot of developers use a standard where
    they define a
    local structure. They can then just append new keys and
    values to this
    local structure throughout the function. Personally I don't
    see much
    advantage to doing this, but to each his|her own.
    I.E.
    <cffunction name="myQryFunction"...>
    <cfargument name="someArgument"...>
    <cfset var local = structNew()>
    <cfset local.something = "FooBar">
    <cfreturn local.something>
    </cffunction>

  • Webservice cffunction returntype="xml" complex datatype problems WSDL

    Ho do I create complex data types in my WSDL when using
    returntype="xml"??
    I have tried a few different things but for the life of me I
    cannot figure it out.

    If you open the Developer Guide of CFMX7
    (cfmx7_dev_guide.pdf) page 909, there is a description how to
    handle complex data types.
    Laksma

  • Form Validation - Error Trapping Not Working.

    Hi,
    I'm a Coldfusion beginner desperately trying to get along with some database work for my site and have come across an annoying error that I just can't solve! I'm sure I'm missing something really basic - I just can't for the life of me figure out what it is!
    Basically, I have a form for users to sign-up. I have introduced several cfif statements and a basic CAPTCHA system to trap errors. If any errors are submitted then they should be displayed in a cfwindow. This process works fine until I specify the form action - after which it is completely ignored and the form contents are written to the database without any validation taking place. Even without specifying the form action the errors won't show in Internet Explorer.
    I really would appreciate any help - it's driving me crazy!
    Thanks in advance,
    Tom.
    Here is the code:
    <cfinclude template="CFIDE/headertemplate.cfm">
    <!-- RANDOM NUMBER GENERATOR  FOR CAPTCHA -->
    <cffunction name="makerandom" returnType="string" output="false">
    <cfset var chars = "23456789ABCDEFGHJKMNPQRSTW">
    <cfset var length = randRange(4,6)>
    <cfset var result = "">
    <cfset var i = "">
    <cfset var char = "">
    <cfscript>
         for(i=1; i <= length; i++) {
              char = mid(chars, randRange(1, len(chars)),1);
              result&=char;
    </cfscript>
    <cfreturn result>
    </cffunction>
    <!-- ERROR TRAPPING -->
      <cfset showForm = true>
      <cfparam name="form.email" default="">
      <cfparam name="form.artistname" default="">
      <cfparam name="form.city" default="">
      <cfparam name="form.postcode" default="">
      <cfparam name="form.pass" default="">
      <cfparam name="form.captcha" default="">
      <cfparam name="form.captchahash" default="">
      <cfparam name="form.terms" default="">
    <cfif isDefined("form.send")>
          <cfset errors = "">
    <cfif len (form.email) LT '4'>
    <cfset errors = errors & "You must include a valid e-mail address.<br />">
    </cfif>
    <cfif find('.',form.email) is '0'>
    <cfset errors = errors & "Your E-mail features no . symbol.<br />">
    </cfif>
    <cfif find('@',form.email) is '0'>
    <cfset errors = errors & "Your E-mail features no @ symbol.<br />">
    </cfif>
    <cfif not len(trim(form.artistname))>
    <cfset errors = errors & "You must include your name.<br />">
    </cfif>
    <cfif not len(trim(form.city))>
    <cfset errors = errors & "You must include your city.<br />">
    </cfif>
    <cfif not len(trim(form.postcode))>
    <cfset errors = errors & "You must include your postcode.<br />">
    </cfif>
    <cfif not len(trim(form.pass))>
    <cfset errors = errors & "You must specify a password.<br />">
    </cfif>
    <cfif len(form.pass) LT '6'>
    <cfset errors = errors & "Password must be between 6 and 10 characters.<br />">
    </cfif>
    <cfif hash(ucase(form.captcha)) neq form.captchahash>
    <cfset errors = errors & "You did not enter the correct Captcha text.<br />">
    </cfif>
    <cfif not len(trim(form.terms))>
    <cfset errors = errors & "You must agree to our Terms and Conditions.<br />">
    </cfif>
    <cfif errors is "">
    <cfset showForm = false>
    </cfif>
    </cfif>
    <cfif showForm>
    <cfset captcha = makerandom()>
    <cfset captchahash = hash(captcha)>
    <cfoutput>
    <h1>Artist Sign-Up</h1>
    <p>Your details are required for sign-up. Mandatory fields are indicated with a *.</p><br/><br/>
    <cfif isDefined("errors")>
    <cfwindow name="formerrors"
    title="Form Errors"
    width="450"
    height="250"
    modal="true"
    initshow="true"
    center="true"
    closable="true"
    minheight="200"
    minwidth="200">
    <center><b>Please correct the following errors and re-submit the form:</b><br /><br/>#errors#
    <br/><a href="javascript:ColdFusion.Window.hide('formerrors');">Close Window</a>
    </center>
    <br/></cfwindow>
    </cfif>
    <!-- FORM CONTENTS -->
    <cfform action="artist_insert.cfm" method="post">
    <table class="signup">
    <tr>
    <td class="noborder" width="200">
      <label for="email">E-Mail Address*:</label>
    </td>
    <td class="noborder" width="156">
    <input type="text" name="email" class="textbox" value="<cfoutput><cfif IsDefined("URL.email")>#URL.email#<cfelse></cfif></cfoutput>"/>
    </td>
    <td class="noborder">
    <cftooltip autoDismissDelay="9999" tooltip="This needs to be a valid e-mail so that<br/> promoters can get in contact with you. <br/>If several people will be using this<br/> account then try and make it a shared<br/> address."><img src="pics/i.jpg" alt="info" border="1" /></cftooltip>
    </td>
    </tr>
    <tr>
    <td class="noborder" width="200">
      Your Password* (6 to 10 chars.):
    </td>
    <td class="noborder">
    <input type="password" class="textbox" name="pass" maxlength="10"/>
    </td>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder" >
    Artist/Band Name*:
    </td>
    <td class="noborder">
    <input type="text" class="textbox" name="artistname" />
    </td>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder">
    City*:
    </td>
    <td class="noborder">
    <input type="text" class="textbox" name="city" />
    </td>
    <td class="noborder">
    <cftooltip autoDismissDelay="9999" tooltip="Entering your locational details enables Gig<br/>Digger to find the events and promoters<br/>in your area. Try specifying a well known<br/>city nearby for the best results."><img src="pics/i.jpg" alt="info" border="1" /></cftooltip>
    </td>
    </tr>
    <tr>
    <td class="noborder">
    Postcode*:
    </td>
    <td class="noborder">
    <input type="text" class="textbox" name="postcode" maxlength="8"/>
    </td>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder">
    Your Contact Number:
    </td>
    <td class="noborder">
    <input type="text" class="textbox" name="contact" maxlength="14"/>
    </td>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <tr>
    <td class="noborder" valign="top" width="200">Please enter the CAPTCHA text in the box below*: </td>
    <td class="noborder" align="left">
    <center><cfimage action="captcha" width="156" height="50" text="#captcha#" border="1">
    <input type="hidden" name="captchaHash" value="#captchaHash#"></center>
    </td>
    <td class="noborder" valign="top">
    <cftooltip autoDismissDelay="9999" tooltip="This is here to ensure that<br/>you're human. It stops abuse <br/>of the site and makes it a safer <br/>place for us all."><img src="pics/i.jpg" alt="info" border="1" /></cftooltip>
    </td>
    </tr>
    <tr>
    <td class="noborder">
    </td>
    <td class="noborder" align="right"><font size="-2"><b><a href="javascript:location.reload(false)">Refresh Page</a></b></font>
    </td>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder"></td>
    <td class="noborder"><input type="text" name="captcha" class="textbox"></td>
    </tr>
    <tr>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder" width="170">Please check this box to confirm that you agree<br/> to our <b><a href="termsandconditions.cfm">Terms and Conditions</a></b>*.
    </td>
    <td class="noborder">
    <input type="checkbox" class="textbox" name="terms" /></td>
    </tr>
    <tr>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder">
    </td>
    <td class="noborder" align="center">
    <cfinput type="image" src="pics/submit.png" name="send" value="Submit" validate="submitonce" border="1">
    </td>
    </tr>
    </table>
    </cfform><br/>
    </cfoutput>
    <cfelse>
    <cfoutput>
    Thank you for submitting your details, #form.name#. You may now log in with your e-mail and password.
    </cfoutput>
    </cfif>
    </td>
    </tr>
    </table>
    <!-- FOOTER START -->
    </body>
    </html>
    ARTIST INSERT PAGE - artist_insert.cfm
    <cfquery datasource="071907cs07to">
    INSERT INTO Artist(    Nsudate,
                        Nemail,
                        Npass,
                        Nname,
                        Ncity,
                        Npostcode,
                        Ncnumber
    VALUES(    ( #Now()# ),
            '#Trim(form.email)#',
            '#Trim(form.pass)#',
            '#Trim(form.artistname)#',
            '#Trim(form.city)#',
            '#Trim(form.postcode)#',
            '#Trim(form.contact)#'
    </cfquery>

    In addition to BreakawayPaul's answer.
    You are making it very difficult to troubleshoot your if/else logic because your code includes all the display stuff.  Since you're a self proclaimed beginner, you might want to try another approach.
    Save your old page and start a new one from scratch.  Solve all your logic problems first.  Display what you need to see with the cfdump tag.
    Here are some hints to make the whole thing easier.
    1.  In your cfform, use the validate and required attributes to catch errors earlier.
    2. You don't have to cfparam every form field.  The form has either been submitted to it hasn't.  If it has, all the fields will be there with the possible exception of checkboxes or radio button, if nothing was selected.

  • Issue with autosuggest on a numeric field

    I have a form with a CFINPUT that has autosuggest to a cfc.
    The cfc runs a query against a varchar field that has only numeric
    values. When the match is made and the lis is returned I get an
    error (Bind failed for autosuggest CUSTOMER, bind value is not a 1D
    array of strings). This only happens with fields that are all
    numeric, if the field has any letters or symbols I do not have this
    issue.
    The data returned is coming back as numeric in scientific
    notation (CFC invocation response: [5.159000038E9]) The data is
    matching on the phone number and that is what is being returned.
    It there a way to correct this issue? Code sample is below.
    <cfinput type="text" name="CUSTOMER" size="10"
    maxlength="10" value="#CUSTOMER#"
    autosuggest="cfc:customerInfo.getCustomerSuggest({DSN},
    {cfautosuggestvalue})">
    here is the function from the CFC:
    <cffunction name="getCustomerSuggest" access="remote"
    returntype="array" output="false">
    <cfargument name="argDB" type="string" required="yes">
    <cfargument name="argCUSTOMER" type="string"
    required="yes">
    <cfset var myarray = ArrayNew(1)>
    <cfquery name="cstInfo" datasource="#argDB#"
    maxrows="25">
    SELECT customer
    FROM custFile
    WHERE customer LIKE <cfqueryparam value="#argCUSTOMER#%"
    cfsqltype="CF_SQL_VARCHAR">
    </cfquery>
    <cfloop query="cstInfo">
    <cfset arrayAppend(myarray, '#customer# ')>
    </cfloop>
    <cfreturn myarray>
    </cffunction>

    I don't understand the actual results desired. But I would
    make my cffunction returntype a string and get rid of the cfloop
    that creates your array. One of my autosuggest cfcs is;
    <cffunction name="getJobsearch" access="remote"
    returnType="string" output="false">
    <cfargument name="term" type="string"
    required="false">
    <cfset var Jqry = "">
    <cfquery name="Jqry" datasource="taxsearchdb">
    SELECT J.CompanyName + ' ' + J.CompanyCity + ' ' + C.State +
    ' ^' + cast(J.JobOrderNumber as varchar) as Jname
    FROM jorder J, Companies C
    WHERE J.CompanyNumber = C.CompanyRecordNumber and
    J.CompanyName LIKE <cfqueryparam cfsqltype="cf_sql_var"
    value="#trim(arguments.term)#%">
    </cfquery>
    <cfreturn ValueList(Jqry.Jname)>
    </cffunction>

  • Auto datagrid

    public function addPriceRow():void{
    var tempPrice:Object= new Object();
    tempPrice = price_RO.init();
    this.price_dg.dataProvider = tempPrice;
    this.price_dg.editable = true;
    this.price_dg.setFocus();
    private function renderPrice():String{
    return String( ); --> here should be the calculations
    <mx:DataGrid id="price_dg" x="10" y="28" width="590"
    height="84">
    <mx:columns>
    <mx:DataGridColumn headerText="Quantity"
    dataField="qty"/>
    <mx:DataGridColumn headerText="Piece"
    dataField="piece"/>
    <mx:DataGridColumn headerText="Product"
    dataField="product"/>
    <mx:DataGridColumn headerText="fee" dataField="fee"/>
    <mx:DataGridColumn headerText="Total" dataField="total"
    labelFunction="renderPrice" editable="false"/>
    </mx:columns>
    </mx:DataGrid>
    <mx:Button x="385" y="0" label="Add Row"
    click="addPriceRow()"/>
    <mx:Button x="494" y="0" label="Delete Row"/>
    Hi All,
    I'm using coldfusion and flex2 in my app.
    Let's said that I'm creating a datagrid like a shopping card
    with Add and
    delete buttons.
    When I add a item, I create a new row and initializing my
    object from the
    cfc with defaul values but they dont show in the datagrid.
    Also I have a total field, I'm using labelFunction but how
    can I get the
    value of the other columns to calculate the total ((qyt *
    piece) + fee))
    I'm new in flex.. please help.
    Any links?
    Tks
    JFB

    hi Tracy,
    As you see I'm trying to use datagrid for input data.
    I can't pass the initial values from my init method in the
    cfc, I try struct
    and still not working
    Do you know why?
    Here is the code...
    <cfscript>
    //Initialize the CFC with the default properties values.
    variables.priceid = 0;
    variables.estimateid = 0;
    variables.qty = 0;
    variables.piece = 0;
    variables.productid= 0;
    variables.fee= 0;
    variables.total = 0;
    </cfscript>
    <cffunction name="init" output="false"
    returntype="any">
    <cfset request.tempStruc = StructNew()>
    <cfloop collection="#variables#" item="i">
    <cfset request.tempStruc[#i#] = variables[#i#]>
    </cfloop>
    <cfreturn request.tempStruc>
    </cffunction>
    The Error is: Type Coercion failed: cannot convert
    mx.utils::ObjectProxy@1c90e7c1 to
    mx.collections.ArrayCollection
    I need to pass these before I can play with the items.
    Tks
    JFB
    "ntsiii" <[email protected]> wrote in message
    news:f4pmkr$4h4$[email protected]..
    > Hmm, does this work at all? You are setting the entire
    dataProvider to
    > the
    > newly initialized new item object. That should result in
    a single row,
    > assuming price_RO.init(); returns a valid dataProvider
    collection.
    >
    > You want instead to use the dataProvider API to add the
    new item.
    >
    > You are not showing a dataProvider assignment in the
    dataGrid. What is
    > the
    > dataProvider?
    >
    > Regarding labelFunction(), the correct method signature
    is:
    > labelFunction(item:Object, column:DataGridColumn):String
    >
    > "item" is a reference to the *entire* item object, so
    contains the values
    > for
    > all the properties in the curent item.
    >
    > "column" is a refernce to the DataGridColumn, so you can
    use that to
    > determine
    > what to return. This lets you have a single
    labelFunction for multiple
    > columns.
    >
    > Tracy
    >

  • Array of cfc object help

    I just picked up coldfusion about a month ago, so my
    coldfusion lingo sucks. I have been programming in C++ for over 5
    years now and will be using a lot of C++ terminology to help avoid
    any confusion. I am writing a cfc function that preforms web
    servicing. This function needs to return an object/class that is
    defined in another coldfusion function. I can do this without a
    problem if I only need to return one instance of this object.
    However, I cannot seem to return an array of this object (I need to
    return multiple instances of this object, kind of like a query, but
    for programming purposes it needs to stay as an object).
    It seems that the webservicing function hates my return type.
    If I try to make an array of the object, it does not like array or
    the object as the return type. However, when I take this function
    out of the cfc, and make it a cfm, it gets the array of objects
    just fine. So, I think I am having issues with the return type on
    the <cffunction> tag. So I came up with the idea of creating
    another object which will hold an array of the first object and
    using the second object as the return type. Here is some psuedo
    code of the function I am working on:
    <cffunction name="SelectGames" access="remote"
    returntype="ArrayOfGames" output="false">
    <!-- arguments --->
    <!--- query --->
    <cfobject component = "myArray" name>
    <cfobject component="games" name="test">
    <cfset counter = 0>
    <cfloop query="getevents">
    <cfset counter = counter + 1>
    <cfset test.Game_id = event_id>
    <cfset test.gameDate = eventdate>
    <cfset test.Starttime = starttime>
    <cfset test.Place = place>
    <cfset test.Level = level>
    <cfset test.Sport = sport>
    <cfset test.Gender = division>
    <cfset test.Opponent = opponent_id>
    <cfset test.Type = type>
    <cfset test.Link = spec_name>
    <cfset myArray.gamesArray[counter] = test>
    </cfloop>
    <cfreturn myArray>
    </cffunction>
    It keeps telling me that it does not recognize the return
    type.
    Here are examples of the two objects I am using from the 2
    dif. cfc files:
    <cfcomponent>
    <cfproperty name="gamesArray" type="array">
    </cfcomponent>
    <cfcomponent>
    <cfproperty name="Game_id" type="numeric">
    <cfproperty name="gameDate" type="date">
    <cfproperty name="Starttime" type="string">
    <cfproperty name="Place" type="string">
    <cfproperty name="Level" type="string">
    <cfproperty name="Sport" type="string">
    <cfproperty name="Gender" type="string">
    <cfproperty name="Opponent" type="string">
    <cfproperty name="Type" type="string">
    <cfproperty name="Link" type="string">
    </cfcomponent>
    Feel free to post any questions to clear anything up, I know
    this is confusing and I probably did a poor job of explaining my
    problem. Also, if I throw this code into a cfm and try to make an
    array of games, it works, this is the code I got it to work with:
    <cfset myArray = newArray(1)>
    <cfloop query="getevents">
    <cfset counter = counter + 1>
    <cfset test.Game_id = event_id>
    <cfset test.gameDate = eventdate>
    <cfset test.Starttime = starttime>
    <cfset test.Place = place>
    <cfset test.Level = level>
    <cfset test.Sport = sport>
    <cfset test.Gender = division>
    <cfset test.Opponent = opponent_id>
    <cfset test.Type = type>
    <cfset test.Link = spec_name>
    <cfset myArray[counter] = test>
    </cfloop>
    I guess my problem is I do not know how to specify a type for
    an array.

    The return type of this FUNCTION would be returnType="array".
    No matter
    what kind of data the array contained.
    That's what I get for fast proofing.
    Ian Skinner wrote:
    > I would have to play with your code more if this does
    not clear it up
    > for you, but lets start with this simple concept first.
    >
    > You mentioned "typing the array" several times.
    ColdFusion is typeless,
    > you don't type an array, it is just array. An array of
    strings is the
    > same as an array of integers which is the same as an
    array of objects.
    >
    > So if you had a function something like this.
    >
    > <cffunction returnType="array" ...>
    > <cfset theArray = arrayNew()>
    >
    > <cfloop ...>
    > <cfset arrayAppend(theArray, newObject)>
    > </cfloop>
    >
    > <cfreturn theArray>
    > </cffunction>
    >
    > The return type of this function would be
    returnType="array". No matter what
    > kind of data the array contained.
    >
    > mwiley63 wrote:
    >> I just picked up coldfusion about a month ago, so my
    coldfusion lingo
    >> sucks. I have been programming in C++ for over 5
    years now and will
    >> be using a lot of C++ terminology to help avoid any
    confusion. I am
    >> writing a cfc function that preforms web servicing.
    This function
    >> needs to return an object/class that is defined in
    another coldfusion
    >> function. I can do this without a problem if I only
    need to return
    >> one instance of this object. However, I cannot seem
    to return an
    >> array of this object (I need to return multiple
    instances of this
    >> object, kind of like a query, but for programming
    purposes it needs to
    >> stay as an object).
    >> It seems that the webservicing function hates my
    return type. If I
    >> try to make an array of the object, it does not like
    array or the
    >> object as the return type. However, when I take this
    function out of
    >> the cfc, and make it a cfm, it gets the array of
    objects just fine.
    >> So, I think I am having issues with the return type
    on the
    >> <cffunction> tag. So I came up with the idea
    of creating another
    >> object which will hold an array of the first object
    and using the
    >> second object as the return type. Here is some
    psuedo code of the
    >> function I am working on:
    >>
    >> <cffunction name="SelectGames" access="remote"
    >> returntype="ArrayOfGames" output="false">
    >> <!-- arguments --->
    >> <!--- query --->
    >> <cfobject component = "myArray" name>
    >> <cfobject component="games" name="test">
    >> <cfset counter = 0>
    >> <cfloop query="getevents">
    >> <cfset counter = counter + 1>
    >> <cfset test.Game_id = event_id>
    >> <cfset test.gameDate = eventdate>
    >> <cfset test.Starttime = starttime>
    >> <cfset test.Place = place>
    >> <cfset test.Level = level>
    >> <cfset test.Sport = sport>
    >> <cfset test.Gender = division>
    >> <cfset test.Opponent = opponent_id>
    >> <cfset test.Type = type>
    >> <cfset test.Link = spec_name>
    >> <cfset myArray.gamesArray[counter] = test>
    >> </cfloop>
    >> <cfreturn myArray>
    >> </cffunction>
    >>
    >> It keeps telling me that it does not recognize the
    return type.
    >> Here are examples of the two objects I am using from
    the 2 dif. cfc
    >> files:
    >> <cfcomponent>
    >> <cfproperty name="gamesArray" type="array">
    >> </cfcomponent>
    >> <cfcomponent>
    >> <cfproperty name="Game_id" type="numeric">
    >> <cfproperty name="gameDate" type="date">
    >> <cfproperty name="Starttime" type="string">
    >> <cfproperty name="Place" type="string">
    >> <cfproperty name="Level" type="string">
    >> <cfproperty name="Sport" type="string">
    >> <cfproperty name="Gender" type="string">
    >> <cfproperty name="Opponent" type="string">
    >> <cfproperty name="Type" type="string">
    >> <cfproperty name="Link" type="string">
    >> </cfcomponent>
    >>
    >> Feel free to post any questions to clear anything
    up, I know this is
    >> confusing and I probably did a poor job of
    explaining my problem.
    >> Also, if I throw this code into a cfm and try to
    make an array of
    >> games, it works, this is the code I got it to work
    with:
    >> <cfset myArray = newArray(1)>
    >> <cfloop query="getevents">
    >> <cfset counter = counter + 1>
    >> <cfset test.Game_id = event_id>
    >> <cfset test.gameDate = eventdate>
    >> <cfset test.Starttime = starttime>
    >> <cfset test.Place = place>
    >> <cfset test.Level = level>
    >> <cfset test.Sport = sport>
    >> <cfset test.Gender = division>
    >> <cfset test.Opponent = opponent_id>
    >> <cfset test.Type = type>
    >> <cfset test.Link = spec_name>
    >> <cfset myArray[counter] = test>
    >> </cfloop>
    >>
    >> I guess my problem is I do not know how to specify a
    type for an array.
    >>

  • Issue with AutoSuggest + UpdateContent

    Hi,
    Using Spry.Utils.updateContent when I load part of a page
    containing an AutoSuggest the AutoSuggest breaks.
    Seems like the XML datasource is not fired in that case. If I
    put the AutoSuggest code out of the destination DIV it works.
    Click here to see what I
    mean
    I'm using v1.5. Any clue ? Thanks.

    I don't understand the actual results desired. But I would
    make my cffunction returntype a string and get rid of the cfloop
    that creates your array. One of my autosuggest cfcs is;
    <cffunction name="getJobsearch" access="remote"
    returnType="string" output="false">
    <cfargument name="term" type="string"
    required="false">
    <cfset var Jqry = "">
    <cfquery name="Jqry" datasource="taxsearchdb">
    SELECT J.CompanyName + ' ' + J.CompanyCity + ' ' + C.State +
    ' ^' + cast(J.JobOrderNumber as varchar) as Jname
    FROM jorder J, Companies C
    WHERE J.CompanyNumber = C.CompanyRecordNumber and
    J.CompanyName LIKE <cfqueryparam cfsqltype="cf_sql_var"
    value="#trim(arguments.term)#%">
    </cfquery>
    <cfreturn ValueList(Jqry.Jname)>
    </cffunction>

  • Cffunction, onSessionEnd throwing an error, please help

    Hello;
    I am using an application.cfc file to run my web site. I
    added an argument for onmissingtemplate and when I did that, it
    made my onSessionEnd statement throw an error:
    this is my statement:
    <cffunction name="onSessionEnd" returnType="void">
    <cfargument name="theSession" type="struct"
    required="true">
    <cfset var duration =
    dateDiff("s",arguments.theSession.created,now())>
    <cflog file="#THIS.name#" text="Session lasted for
    #duration# seconds.">
    </cffunction>
    and this is the error:
    Invalid CFML construct found on line 85 at column 1.
    ColdFusion was looking at the following text:
    <
    The CFML compiler was processing:
    < marks the beginning of a ColdFusion tag.Did you mean LT
    or LTE?
    The error occurred in C:\Websites\4npp8b\Application.cfc:
    line 85
    83 : </cfcomponent>
    84 :
    85 : <cffunction name="onSessionEnd" returnType="void">
    86 : <cfargument name="theSession" type="struct"
    required="true">
    87 : <cfset var duration =
    dateDiff("s",arguments.theSession.created,now())>
    I don't know if this will make a difference, but here is my
    onsessionstart function:
    <cffunction name="onSessionStart" returntype="any"
    output="true">
    <cfset SESSION.created = now()>
    </cffunction>
    I can't figure out what I did wrong to make it throw that
    error. Any ideas?
    CFmonger

    never mind, I figured it out. sorry to bother.

  • Cffunction error

    The argument TEAM passed to function SearchRes() is not of type numeric.
    If the component name is specified as a type of this argument, the reason for this error might be that a definition file for such component cannot be found or is not accessible.
    The error occurred in C:\Inetpub\wwwroot\search.cfc: line 4
    2 :
    3 :      <cffunction name="SearchRes" access="public" returntype="query">
    4 :        <cfargument name="DSN" type="string" required="yes">
    5 :     <cfargument name="Role" type="string" required="no">
    6 :     <cfargument name="Team" type="numeric" required="no">
    Please look at the above error...any help app...
    code ------------------------->
    <cfcomponent hint="This cfc does search...">
    <cffunction name="SearchRes" access="public" returntype="query">
       <cfargument name="DSN" type="string" required="yes">
        <cfargument name="Role" type="string" required="no">
        <cfargument name="Team" type="numeric" required="no">
        <cfargument name="Level" type="numeric" required="no">
        <cfargument name="zone" type="numeric" required="no">
        <cfargument name="Dept" type="numeric" required="no">
        <cfargument name="location" type="numeric" required="no">
        <cfargument name="csgid" type="string" required="no">
        <cfargument name="status" type="string" required="no">
        <cfargument name="filter" type="string" required="no">
        <cfargument name="bosseid" type="string" required="no">
           <cfdump var="#arguments#">    
          <cfquery datasource="#arguments.DSN#" name="SearchRes">
            Select
              r.First_name,
              r.Last_name,
              r.EID,
              r.tech_id,
              r.title,
              r.hire_date,
              r.rehire_date,
              l.location,
              d.department
            from
              OPS$RMS.REF_resource r,
              OPS$RMS.Ref_department d,
              OPS$RMS.REF_Location l
            where
              r.location_code = l.location_code
              And r.department_code = d.department_code
              <cfif arguments.role neq "">
               And r.role_code = '#arguments.role#'
              </cfif>
              <cfif arguments.Team neq "">
               And r.team_code = #arguments.team#
              </cfif>
              <cfif arguments.level neq "">
               And r.level_code = #arguments.level#
              </cfif>
              <cfif arguments.zone neq "">
               --And r.zone_code = #arguments.zone#
              </cfif>
              <cfif arguments.dept neq "">
               And r.department_code = #arguments.dept#
              </cfif>
              <cfif arguments.location neq "">
               And r.location_code = #arguments.location#
              </cfif>
              <cfif arguments.csgid neq "">
               And r.csg_operator_id like '#arguments.csgid#%'
              </cfif>
              <cfif arguments.status neq "">
               And r.status = '#arguments.status#'
              </cfif>
              <cfif arguments.filter neq "">
                And
                r.EID = '#arguments.filter#%'
                OR r.First_name like '#arguments.filter#%'
                OR r.last_name like '#arguments.filter#%'
                OR r.tech_id like '#arguments.filter#%'
              </cfif>
              <cfif arguments.bosseid neq "">
               And r.boss_id = '#arguments.bosseid#%'
              </cfif>
          </cfquery>  
          <cfreturn SearchRes>
    </cffunction>
    </cfcomponent>

    craigkaminsky wrote:
    Might not be an issue but, while your Team variable can be null, the cfargument tag types the variable as a numeric value (as opposed to any or whatever). Depending on what you're supplying this could be a source of the error.
    As mentioned we would have to see the code.  But that could well be the problem.  There is really no concept of a "null" form field.  If you are passing in the values of text fields, empy fields will be treated as an empty string "".  Since an empty string is not numeric, it would cause exactly the error you are describing.
    <!--- simulate an empty form field ---->
    <cfset form.someField = "" />
    <cfoutput>#test(form.someField)#</cfoutput>
    <cffunction name="test" returntype="string">
        <cfargument name="someValue" type="numeric" />
        <cfreturn "okay"/>
    </cffunction>

  • The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or

    I have taken the cfdump for tmpqry and it shows all data for
    the range ( No error at this step ) . But when we exceute this
    dbquery we get below mentioned error .
    <cfquery name="qry" dbtype="query" >
    SELECT *
    FROM tmpqry
    ORDER BY #arguments.colSort# ASC
    </cfquery>
    senerio:
    I am using createobject to create a reference for component
    and call MDArraySort function in the cfc and getting this error .
    'The system has attempted to use an undefined value, which
    usually indicates a programming error, either in your code or some
    system code.
    Null pointer is undefined.... '
    i am using this code in a cfc file.
    <cffunction name="MDArraySort" Returntype="query"
    access="public" >
    <cfargument name="colArray" type="array"
    required="true">
    <cfargument name="colNames" type="string"
    required="true">
    <cfargument name="colSort" type="string"
    required="true">
    <cfargument name="sensorIDs" type="string"
    required="true">
    <cfscript>
    var tmpqry = Querynew(arguments.colNames);
    var qRow = QueryAddRow(tmpqry, Arraylen(arguments.colArray)
    </cfscript>
    <cfloop from="1" to="#Arraylen(arguments.colArray)#"
    index="qRowIndex">
    <cfscript>
    sIndexinSensorIDs = colArray[qRowIndex]["SENSOR"]&"##";
    Temp_readin_code =
    colArray[qRowIndex]["READING_CODE"]&"##";
    QuerySetCell(tmpqry, 'SENSOR', sIndexinSensorIDs,
    qRowIndex);
    QuerySetCell(tmpqry,
    'TYPE',javacast('String',colArray[qRowIndex]["TYPE"]), qRowIndex);
    QuerySetCell(tmpqry, 'TIMESTAMP2',
    LSParseDateTime(colArray[qRowIndex]["TIMESTAMP2"]), qRowIndex);
    QuerySetCell(tmpqry,
    'ORDER_BY_PARAM',javacast('String',colArray[qRowIndex]["ORDER_BY_PARAM"]),
    qRowIndex);
    QuerySetCell(tmpqry, 'READING_CODE',Temp_readin_code ,
    qRowIndex);
    QuerySetCell(tmpqry,
    'READING',javacast('String',colArray[qRowIndex]["READING"]),
    qRowIndex);
    QuerySetCell(tmpqry,
    'PK_READING',javacast('String',colArray[qRowIndex]["PK_READING"]),
    qRowIndex);
    QuerySetCell(tmpqry,
    'ALARM_STATUS',javacast('String',colArray[qRowIndex]["ALARM_STATUS"]),
    qRowIndex);
    QuerySetCell(tmpqry, 'DURATION',
    javacast('String',colArray[qRowIndex]["DURATION"]), qRowIndex);
    QuerySetCell(tmpqry,
    'DESCRIPTION',javacast('String',colArray[qRowIndex]["DESCRIPTION"]),
    qRowIndex);
    </cfscript>
    </cfloop>
    <cfquery name="qry" dbtype="query" >
    SELECT *
    FROM tmpqry
    ORDER BY #arguments.colSort# ASC
    </cfquery>
    <cfreturn qry >
    </cffunction>
    It is working fine for some date range and and getting above
    mentioned error in sone situation .

    Hi All ,
    Thank you for your support ,
    Finally i have fix the issue using some changes in my
    function in cfc .
    <cffunction name="MDArraySort" Returntype="query"
    access="public" >
    <cfargument name="colArray" type="array"
    required="true">
    <cfargument name="colNames" type="string"
    required="true">
    <cfargument name="colSort" type="string"
    required="true">
    <cfargument name="sensorIDs" type="string"
    required="true">
    <cfscript>
    //Declare variable collection used in function as local
    --->
    var tmpqry =
    Querynew(arguments.colNames,"CF_SQL_VARCHAR,CF_SQL_VARCHAR,CF_SQL_DATE,CF_SQL_VARCHAR,CF_ SQL_VARCHAR,CF_SQL_VARCHAR,CF_SQL_VARCHAR,CF_SQL_VARCHAR,CF_SQL_VARCHAR,CF_SQL_VARCHAR");
    var qRow = QueryAddRow(tmpqry,
    Arraylen(arguments.colArray));
    </cfscript>
    <cfloop from="1" to="#Arraylen(arguments.colArray)#"
    index="qRowIndex">
    <cfscript>
    // Populate the query table
    QuerySetCell(tmpqry, 'SENSOR',
    colArray[qRowIndex]["SENSOR"], qRowIndex);
    QuerySetCell(tmpqry,
    'TYPE',arguments.colArray[qRowIndex]["TYPE"], qRowIndex);
    QuerySetCell(tmpqry, 'TIMESTAMP2',
    LSParseDateTime(arguments.colArray[qRowIndex]["TIMESTAMP2"]),
    qRowIndex);
    QuerySetCell(tmpqry,
    'ORDER_BY_PARAM',arguments.colArray[qRowIndex]["ORDER_BY_PARAM"],
    qRowIndex);
    QuerySetCell(tmpqry, 'READING_CODE',
    colArray[qRowIndex]["READING_CODE"] , qRowIndex);
    QuerySetCell(tmpqry,
    'READING',arguments.colArray[qRowIndex]["READING"], qRowIndex);
    QuerySetCell(tmpqry,
    'PK_READING',arguments.colArray[qRowIndex]["PK_READING"],
    qRowIndex);
    QuerySetCell(tmpqry,
    'ALARM_STATUS',arguments.colArray[qRowIndex]["ALARM_STATUS"],
    qRowIndex);
    QuerySetCell(tmpqry, 'DURATION',
    arguments.colArray[qRowIndex]["DURATION"], qRowIndex);
    QuerySetCell(tmpqry,
    'DESCRIPTION',arguments.colArray[qRowIndex]["DESCRIPTION"],
    qRowIndex);
    </cfscript>
    </cfloop>
    <cfquery name="qry" dbtype="query" >
    SELECT *
    FROM tmpqry
    ORDER BY #arguments.colSort# ASC
    </cfquery>
    <cfreturn qry >
    </cffunction>
    Rajesh
    SCMS
    India

  • How to handle Coldfusion SOAP Web Service Errors

    Hi,
    I have just created simple wsdl example:
    My Component:
    <cfcomponent displayname="mytest">
        <cffunction name="service_login_authentication" access="remote" output="true" returntype="any" hint="Returns login">
         <cfargument name="login" type="string" required="yes">
            <cfargument name="password" type="string" required="yes">
              <cfif #arguments.login# eq "abcdef" and #arguments.password# eq "123456">
                      <cfxml variable="soapRes">                
                            <kps_response>
                                <message>OK</message>
                                <token>354dfdffsdf</token>
                             </kps_response>
                        </cfxml>
                 <cfelse>
                         <cfthrow type="MyException" message="INVALID LOGIN" errorcode="1000" />
             </cfif>        
          <cfreturn soapRes >
        </cffunction>
    </cfcomponent>
    Its generating wsdl and no problem with response but when generating any error like username and password does not match then it's generating fault code like this:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
          <soapenv:Fault>
             <faultcode>soapenv:Server.userException</faultcode>
             <faultstring>coldfusion.xml.rpc.CFCInvocationException: [coldfusion.runtime.CustomException : INVALID LOGIN. ]</faultstring>
             <detail>
                <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">HOST_NAME</ns1:hostname>
             </detail>
          </soapenv:Fault>
       </soapenv:Body>
    </soapenv:Envelope>
    But I want customize Fault Code like this:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
          <soapenv:Fault>
             <faultcode>1000</faultcode>
             <faultstring>INVALID LOGIN</faultstring>
          </soapenv:Fault>
       </soapenv:Body>
    </soapenv:Envelope>
    Fault Code and Fault String should be customize and I don't want detail tag completely. In old ColdFusion version like ColdFusion 8 displaying detail tag with <ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/"> coldfusion.xml.rpc.CFCInvocationException: and so on.
    Any suggestions on how to create customize faultcode and faultstring is very helpful.
    Thanks!!

    But my component is not produces this fault code:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                   
                                <soapenv:Body>                   
                                      <soapenv:Fault>                   
                                         <<faultcode>1000</faultcode>                   
                                                   <faultstring>INVALID LOGIN</faultstring>                   
                                      </soapenv:Fault>                   
                                   </soapenv:Body>                   
    </soapenv:Envelope>
    What is your ColdFusion Version as i have checked in ColdFusion 11 developer edition and ColdFusion 8 enterprise which is on window 2003 server.
    Could you please check my below component, did i am doing something wrong.
    <cfcomponent output="false">
        <cffunction name="service_login_authentication" access="remote" output="true" returntype="any" hint="Returns login">
         <cfargument name="login" type="string" required="yes">
            <cfargument name="password" type="string" required="yes">
      <cfset var isLoginValid = False>
            <cftry>
              <cfif #arguments.login# eq "1111" and #arguments.password# eq "1111">
                  <cfset isLoginValid = True>
                </cfif>
                 <cfif isLoginValid>
                        <cfsavecontent variable="soapRes"><?xml version="1.0" encoding="UTF-8"?>           
                           <kps_response>           
                               <message>OK</message>           
                               <token>354dfdffsdf</token>           
                            </kps_response>           
                         </cfsavecontent>           
                    <cfelse>           
                        <cfthrow type="MyException" message="INVALID LOGIN" errorcode="1000" />           
                    </cfif>
                      <cfcatch type="MyException">           
                         <cfsavecontent variable="soapRes">               
                                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                   
                                <soapenv:Body>                   
                                      <soapenv:Fault>                   
                                         <<cfoutput><faultcode>#cfcatch.errorCode#</faultcode>                   
                                                   <faultstring>#cfcatch.message#</faultstring></cfoutput>                   
                                      </soapenv:Fault>                   
                                   </soapenv:Body>                   
                                </soapenv:Envelope>                  
                           </cfsavecontent>
                    </cfcatch>
                </cftry>     
          <cfreturn soapRes >
        </cffunction>
    </cfcomponent>
    If my component is okay then may be possible some setting in ColdFusion administrator. i have checked in SoapUI as well via getSoapResponse method.

Maybe you are looking for