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 8593847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:04:53+00:00 2026-06-12T00:04:53+00:00

I am trying to work out the correct <cfscript> syntax for calling a dynamic

  • 0

I am trying to work out the correct <cfscript> syntax for calling a dynamic method within ColdFusion 9. I have tried a number of variations and had a good search around.

<cfinvoke> is clearly the tag I want, sadly however I cannot use this within my pure cfscript component as it was implemented in ColdFusion 10.

i.e coldfusion 9 dynamically call method

I have tried the following within my CFC:

/** Validate the method name **/
var resources = getResources();
if (structKeyExists(variables.resources, name)) {
  variables.resourceActive[name] = true;
  var reflectionMethod = resources[name];
  var result = "#reflectionMethod.getMethodName()#"(argumentCollection = params);
}

Where the return value of reflectionMethod.getMethodName() is the method name I want to call. It is 100% returning the correct value (the name of the method) where that method is correctly defined and accessible,

My error is a syntax error on that line.

  • 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-06-12T00:04:54+00:00Added an answer on June 12, 2026 at 12:04 am

    You don’t want to get the method name, you want to get the actual method, eg something like:

    function getMethod(string method){
        return variables[method];
    }
    

    The call that, thus:

    theMethod = getMethod(variableHoldingMethodName);
    result = theMethod();
    

    Unfortunately one cannot simply do this:

    result = getMethod(variableFoldingMethodName)();
    

    Or:

    result = myObject[variableFoldingMethodName]();
    

    As the CF parser doesn’t like the double-up of the parentheses or brackets.

    The caveat with the method I suggested is that it pulls the method out of the CFC, so it will be running in the context of the calling code, not the CFC instance. Depending on the code in the method, this might or might not matter.

    Another alternative is to inject a statically-named method INTO the object, eg:

    dynamicName = "foo"; // for example
    myObject.staticName = myObject[dynamicName];
    result = myObject.staticName(); // is actually calling foo();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to work out the correct way of blocking access to
I have a problem trying to work out the correct algorithm to calculate a
I'm trying to work out the correct pattern to use for a Singleton that
I am trying to work out the best practice for my problem. I have
I am trying to work out the correct behavior to string multiple callbacks together.
I've been trying to work this out for 2 days now and I have
I have been trying for quite a while to work out how to accomplish
I am trying to work out client side validation and have followed a couple
I'm trying to work out the correct way to handle populating an array with
I have a month and day; I'm trying to work out the next date

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.