[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 801
  • Last Modified:

Tricky Question on using StructFind or StructFindValue

Hi,

I am trying to write this query that has some conditional logic.  I urgently need a solution if anyone is around.

I get the error (below) when trying to do this:

You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.

My code snippet from the actual query is as follows:

<cfif StructFindValue(#currentStructure.List#, "ABC")>,Some_Code, Some_Amount</cfif>

and then in the   VALUES part of the query I have:

( <cfif StructFindValue(#currentStructure.List#, "ABC")>,'XL',40</cfif>

I am trying to find the value "ABC" in the structure and if so, then add the columns Some_Code and Some_Amount with values of  'XL' and '40'

Can someone PLEASE tell me where I am going wrong?  Should I use StructFind? or StructFindValue?

-WS
0
Westside2004
Asked:
Westside2004
  • 2
  • 2
1 Solution
 
MauseCommented:
Hi

How does your structure look like? (use cfdump)
What is in #currentStructure.List#

if #currentStructure.List# contains 'abc' (string and not a structure) try this:
StructFindValue(#currentStructure#, "ABC")

Mause
0
 
Tacobell777Commented:
Are you trying to find a key in the structure or a value in the structure?
Use structFind to find a key and structFindValue to find a value

are you sure currentStructure.List is a structure and not a list , i.e. string?
0
 
Westside2004Author Commented:
Hi,

I think its a list.... i did a dump and its comma separated....

Is it possible it could be a list within a structure?

Thanks

0
 
MauseCommented:
Yes you could have a list in a structure
to see if  "ABC" is in the list

#ListFind(currentStructure.List, "ABC")#
0
 
Westside2004Author Commented:
Yes, that worked.

Thanks a BIG BUNCH!!!

HIGHLY appreciated!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now