• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Dynamic named arguments

Explorer ,
Apr 20, 2008 Apr 20, 2008

Copy link to clipboard

Copied

Hi,

I have 2 cfc methods one receives 3 arguments, id,fieldid,fieldvalue. Where fieldid is a db column name and fieldvalue is the value of that field. I want to pass this info to another method which accepts many more optional arguments. I would like to use the arguments.field as the name of an argument for the 2nd method

e.g. my2ndmethod(arguments.fieldid=arguments.fieldvalue)

However, this doesn't seem to be working. Is there anyway to do this other than using a switch case on arguments.fieldid and then hardcoding each possible fieldid in each cfcase?

Any ideas/suggestions/workarounds?

Many thanks,

Dave
TOPICS
Advanced techniques

Views

257

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Apr 22, 2008 Apr 22, 2008
Problem solved. I used cfinvoke to invoke the second method and then used cfinvokeargument name="#arguments.fieldid#" value="#arguments.fieldvalue#" and it works a treat!!

Cheers,

Dave

Votes

Translate

Translate
LEGEND ,
Apr 20, 2008 Apr 20, 2008

Copy link to clipboard

Copied

if I understand the question correctly,
argumentcollection=arguments
is one of my favourite attributes when using cfinvoke

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 20, 2008 Apr 20, 2008

Copy link to clipboard

Copied

But wouldn't argumentcollection pass arguments.fieldid and arguments.field value to the 2nd method? My second method would not know what fieldid was.

arguments.fieldid could be anything for that particular data table e.g. firstname or lastname. arguments.fieldvalue holds the corresponding value of that field e.g. Dave or Phipps.

My 2nd method has arguments for firstname, lastname so argumentCollection would not fit in this situation.

Although could I use cfinvokeargument?? I'll try it in the morning! (00:22 here).

I think I have had a lightbulb moment.

Thanks Dan, you might have pointed me in the right direction!

Cheers,

Dave

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 22, 2008 Apr 22, 2008

Copy link to clipboard

Copied

LATEST
Problem solved. I used cfinvoke to invoke the second method and then used cfinvokeargument name="#arguments.fieldid#" value="#arguments.fieldvalue#" and it works a treat!!

Cheers,

Dave

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation