Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1898822
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:49:14+00:00 2026-05-17T06:49:14+00:00

Ok, I have instantiated an object and all is fine. I am able to

  • 0

Ok, I have instantiated an object and all is fine. I am able to call various methods of that object easily, such as myobject.getId(), myObject.getName() , etc etc. These examples all return either a string or numeric value.

Now I have another method that returns a query. I’ve cfdumped what is returned by the method and it is indeed a query that’s being returned.

By when I try to cfloop through the query I get an error.

Here’s the cfloop code:

<cfloop query="myObject.myFunction()">
    <p><cfoutput>#myObject.myFunction().title#</cfoutput></p>
</cfloop>

The error I get references the very first line and says:

invalid variable declaration [myObject.myFunction()]

Any thoughts? Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:49:15+00:00Added an answer on May 17, 2026 at 6:49 am

    OK, so you just need to change your code slightly so you are doing call to run the query first, e.g.

    <cfset qData = myObject.myFunction() />
    

    And then you can loop over it.

    <cfloop query="qData">
        <p><cfoutput>#qData.title#</cfoutput></p>
    </cfloop>
    

    The reason is that the <cfloop/> tag expects a query object, not a reference to a function.

    You could try to see if <cfloop query="#myObject.myFunction()#"> works (with the #’s) but I’m not sure if it will. Besides, each call inside the loop i.e. #myObject.myFunction().title is going to re-run the query. Not good obviously!

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some object that is instantiated in code behind, for instance, the XAML
I have a javascript object (that is instantiated several times) that contains setTimeout functions.
Suppose that we have previously instantiated three objects A, B, C from class D
We have a Rails app that instantiates a SWF object 16 times (it has
I have an object that I instantiate - it's quite nifty as it also
I have a few classes that are instantiated using ninject Session Scoping - because
I have a masterpage file which is called Masterpage.master which works fine with all
I have an interface that defines the behaviour of an object that does some
All the singleton patterns I have seen use a reference to the object to
Alright. I have created a custom object that I am using to build a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.