Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7537657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:54:39+00:00 2026-05-30T06:54:39+00:00

I have a struct that’s inside an array that is nested inside another struct,

  • 0

I have a struct that’s inside an array that is nested inside another struct, like so: Arguments.cart.data.Items[x].Labels.Pkg.Title (x is an index, as I’m looping over Items).

Items is an array while Labels, Pkg, and Title are nested structs.

Title does not always exist. So I would like to check for it. However, using structFindKey returns an error

You have attempted to dereference a scalar variable of type class coldfusion.runtime.Array as a structure with members

I could just look inside Arguments.cart.data; however, if there are multiple rows in the array, some rows may contain Title while others do not. So I want to check for Title inside each Items.

I’ve also tried arrayFind, but then I get the error

Struct cannot be used as an array

I’m at a loss here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:54:40+00:00Added an answer on May 30, 2026 at 6:54 am

    This will do the job

    <cfscript>
        for (i=1;i<=ArrayLen(arguments.cart.data.Items);i++) {
            tempI = arguments.cart.data.Items[i];
            if (IsDefined('tempI.Labels.Pkg.Title')) {
                // It exists
            } else {
                // It doesn't
            }
        }
    </cfscript>
    

    IsDefined doesn’t play nicely with arrays, but by assigning each element of the array to the temp value you are then able to refer to it within IsDefined.

    Alternatively you can do the following, if you prefer StructKeyExists

    <cfscript>
        for (i=1;i<=ArrayLen(arguments.cart.data.Items);i++) {
            tempI = arguments.cart.data.Items[i];
            if (
                StructKeyExists(tempI,'Labels')
                && StructKeyExists(tempI.Labels,'Pkg')
                && StructKeyExists(tempI.Labels.Pkg,'Title')
            ) {
                // It exists
            } else {
                // It doesn't
            }
        }
    </cfscript>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code that looks something like: struct Data { int value; };
Say we have a struct that it's data is provided by un-managed byte array
I have a struct that looks something like this: [StructLayout(LayoutKind.Sequential)] public struct in_addr {
I have a struct that I initialize like this: typedef struct { word w;
I have an unmanaged struct I'd like to marshal to c sharp that looks
I have a struct that I'd like to output using either 'std::cout' or some
Say I have a struct that looks like this (a POD): struct Foo {
I have a struct that's used in my internet application, which looks like: struct
I have a struct that takes a function pointer, like this: typedef int (*node_transition_func)(
I have a C++ struct that looks like this: struct unmanagedstruct { int flags;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.