Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Problem Calling Query in Custom Tag

New Here ,
Dec 04, 2008 Dec 04, 2008
I am using this code to call a custom tag called broadcast.cfm

<cf_broadcast query="fe" orgID = "4">

The query fe is an included file on my site and is available to the page I'm calling the custom tag from.

In the custom tag I am referencing the query like:

<cfloop query="#attributes.query#">

but I keep getting this error:
"The value of the attribute query, which is currently "fe", is invalid. "

I must be missing something really simple here but can't figure out what.
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Dec 04, 2008 Dec 04, 2008
rdk8487 wrote:
> In the custom tag I am referencing the query like:
> <cfloop query="#attributes.query#">
> but I keep getting this error:
> "The value of the attribute query, which is currently "fe", is invalid. "

It is a scoping problem. The query is defined in the calling page. To access it by name, within the custom tag, use the "caller" scope.

<cfloop query="caller.#attributes.nameOfTheQuery#">

Translate
LEGEND ,
Dec 04, 2008 Dec 04, 2008
"fe" is a string.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 04, 2008 Dec 04, 2008
can you elaborate? I'm not sure what you're telling me.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 04, 2008 Dec 04, 2008
<cf_broadcast query="fe" orgID = "4"> <!--- here "fe" is string --->

<cf_broadcast query="#fe#" orgID = "4"> <!--- add pound signs to treat fe as a variable name --->

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 04, 2008 Dec 04, 2008
Thanks. I tried that and got:

"Complex object types cannot be converted to simple values."

Since fe is the name of the query I'm not sure why it should be treated as a variable though.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 04, 2008 Dec 04, 2008
If the pound signs are omitted CF will assume "fe" is a string literal and not a variable. It might help if you could post your code. I was able to use #fe# without seeing an error. I have attached the sample code for the custom tag and calling page.

Using "fe" as the value of query displays "Value is not a query", using "#fe#" displays the list of column names for the query object. Note for my example the orgID attribute is not used.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 04, 2008 Dec 04, 2008
Put these two lines at the start of your custom tag.

<cfdump var="#attributes#">
<cfflush>

Then start passing various things for the query attibute. That will help you troubleshoot.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 04, 2008 Dec 04, 2008
rdk8487 wrote:
> In the custom tag I am referencing the query like:
> <cfloop query="#attributes.query#">
> but I keep getting this error:
> "The value of the attribute query, which is currently "fe", is invalid. "

It is a scoping problem. The query is defined in the calling page. To access it by name, within the custom tag, use the "caller" scope.

<cfloop query="caller.#attributes.nameOfTheQuery#">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 04, 2008 Dec 04, 2008
quote:

Originally posted by: -==cfSearching==-
rdk8487 wrote:
> In the custom tag I am referencing the query like:
> <cfloop query="#attributes.query#">
> but I keep getting this error:
> "The value of the attribute query, which is currently "fe", is invalid. "

It is a scoping problem. The query is defined in the calling page. To access it by name, within the custom tag, use the "caller" scope.

<cfloop query="caller.#attributes.nameOfTheQuery#">




If the query object is passed to the custom tag via an attribute you shouldn't need the caller scope. See attached sample.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 04, 2008 Dec 04, 2008
LATEST
quote:

Originally posted by: JR "Bob" Dobbs
If the query object is passed to the custom tag via an attribute you shouldn't need the caller scope. See attached sample.



Yes, I believe you do because the query object resides in the caller scope. Using query="attributes.query" fails because CF treats it as a literal string.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources