1 Reply Latest reply on Apr 8, 2014 8:29 AM by Carl Von Stetten

    Need help with auto suggest - Return multiple fields

    siriiven

      I am having a hard time getting my autosuggest to work. I have a cfinput where a person can type in a last name. I then want to return the full name and employee ID of the person and bind them to two different cfinputs. Here is my cfc:

       

      <cfcomponent output="false">

       

       

                <cffunction name="getPerson" access="remote" returntype="array">

                          <cfargument name="search" type="any" required="false" default="">

       

       

                          <!--- Define variables --->

       

                           <cfset var data = "">

        <cfset var result = ArrayNew(2)>

        <cfset var i=0>

       

       

                          <!--- Query Location Table --->

                          <cfquery name="data" datasource="ds" cachedwithin="#CreateTimeSpan(0,14,0,0)#">

                                    SELECT PERSONNEL.NAME_LAST_FIRST_MID, PERSONNEL.EMPLID, MST_LD.EMPLID

      FROM MST_LD LEFT JOIN PERSONNEL ON MST_LD.SYREDU_SUID = PERSONNEL.EMPLID

      WHERE ((MST_LD.PRIMARY_AFFIL_STATUS)= 'Active') AND ((MST_LD.EMPLID) Is Not Null)) AND PERSONNEL.NAME_LAST like <cfqueryparam cfsqltype="cf_sql_varchar" value="#ucase(arguments.search)#%" />

       

       

       

       

       

       

                                    order by          name_last, name_first , EMPLID ASC

                          </cfquery>

       

       

       

       

       

       

       

                    <cfloop index="i" from="1" to="#data.RecordCount#">

                    <cftry>

               <cfset result[i][1]=data.NAME_LAST_FIRST_MID[i]>

               <cfset result[i][2]=data.EMPLID[i]>

               <cfcatch></cfcatch>

               </cftry>

              

            </cfloop>

             

       

       

       

       

       

       

       

       

                          <!--- And return it as a List --->

                          <cfreturn result>

       

       

                </cffunction>

       

       

       

       

       

       

       

       

      </cfcomponent>