Skip to main content
Inspiring
October 30, 2007
Question

Where is the error hiding

  • October 30, 2007
  • 2 replies
  • 532 views
CFC Code:
<cffunction name="comp_extList"
access="remote"
returntype="query"
description="Get a list of employees, phone extensions, and departments">

<cfargument name="abbrCode" required="yes" />

<cfargument name="searchBox" required="no" />
<cfset searchBox = UCASE("#arguments.searchBox#") />
<cfldap name="phoneList"
server="#cfc.ldap.server#"
username="#cfc.ldap.user#@bii.corp"
password="#cfc.ldap.key#"
action="query"
filter="company=#arguments.abbrCode#"
start="dc=bii, dc=corp"
scope="subtree"
attributes="sn,givenName,telephoneNumber,department"
sort="sn ASC"
port="389" />

<cfif len(arguments.searchBox) GT 0>
<cfquery name="phoneList" dbtype="query">
SELECT *
FROM phoneList
WHERE (UPPER(givenName) LIKE '%#searchBox#%'
OR UPPER(sn) LIKE '%#searchBox#%'
OR telephoneNumber LIKE '%#searchBox#%')
AND telephoneNumber <> ''
</cfquery>
<cfelse>
<cfquery name="phoneList" dbtype="query">
SELECT sn,givenName,telephoneNumber,department
FROM phoneList
WHERE telephoneNumber <> ''
</cfquery>
</cfif>

<cfreturn phoneList>

</cffunction>

I need to pass entered information for a search, but I receive error message:
element searchbox is undefined in arguments.
    This topic has been closed for replies.

    2 replies

    jkgivenAuthor
    Inspiring
    October 30, 2007
    Hmmm....
    Well that does get rid of the error message, but no results are found either. I'll keep digging.
    Inspiring
    October 30, 2007
    Dump the results to see where the problem is - with the ldap query or QoQ.
    October 30, 2007
    The error is not hiding at all actually. First, I recommend scoping all your variables. Inside a <cffunction> you can use <cfset var myLocalVar = "" /> to keep the variables local. But I noticed that you have this line:

    <cfargument name="searchBox" required="no" />

    The searchBox argument is not required, but you're using it the very next line:

    <cfset searchBox = UCASE("#arguments.searchBox#") />

    Since the argument is not required, it may not be passed in and hence won't exist in the arguments scope. The way to fix this is giving it a default value like so:

    <cfargument name="searchBox" required="no" default="" type="string" />

    That way if nothing is passed, Arguments.searchBox will still have a value.