Skip to main content
Known Participant
November 29, 2012
Question

How do I Trim a value coming from a CFC?

  • November 29, 2012
  • 1 reply
  • 2019 views

Hi!


I have a simple CFC which gets records from a database.

I have then created a ColdFusion page and used <cfobject> to make an instance of the CFC. I then use this instance to populate a <cfselect> form element.

The problem is that the field has too many spaces in it so I need to Trim it.


Here is my code:


<cfobject component = "globalFilters" name="globalFilters">

<cfinvoke component="#globalFilters#" method="filters_Status" returnvariable="rsStatus">

<cfselect name="Status"

query="rsStatus"

value="#Trim(Status)#"

display="Status">

</cfselect>


Unfortunately it CF says "Status" is not defined and fails. But if I remove the Trim method then it works fine.

How do I trim the value in the select list?

    This topic has been closed for replies.

    1 reply

    Inspiring
    November 29, 2012

    Rather than trimming it after the fact, why don't you just not add the spurious whitespace in the first place?  Aren't you attempting to treat the symptom, not the problem?

    --
    Adam

    Inspiring
    November 29, 2012

    Once you get rsStatus, loop through it and use QuerySetCell to trim the status values.