I’m passing form variables in a cfinvoke argument collection:
<cfinvoke component="#application.componentPath#.account" method="updateServices" argumentcollection="#form#" />
But I keep getting the error: “String index out of range: 0 null”
I’ve narrowed it down to something to do with the form variables passed in the argumentcollection. When I do a <cfdump var="#form#">, it looks like this:
form - struct
EMAIL_1 wendy
EMAIL_2 [empty string]
EMAIL_3 [empty string]
EMAIL_4 [empty string]
FIELDNAMES EMAIL_1,EMAIL_2,EMAIL_3,EMAIL_4,
(I can’t do a screenshot of the struct so you’ll have to imagine it.)
If I lose the argumentcollection from the cfinvoke, the error disappears.
The receiving CFC:
<cffunction name="updateServices" access="public" output="true" returntype="void">
<!--- deliberately emptied to see if it was anything inside the cfc causing the issue--->
</cffunction>
Any assistance appreciated.
We can’t see what’s going on in your component, so this is a guess. When you use
argumentcollectionwith<cfinvoke>and pass in a struct, the struct is broken out in the component as if its elements had been passed in as individual arguments. So if you have:…then inside the component you’ll have:
You will not have
arguments.foo.this, norfoo.this. So if you want to pass in your form scope and have it encapsulated inside the component, you can try this:Then, inside the invoked component method, you’d be able to use:
…etc. You might also look into
<cfinvokeargument>. If none of this helps, maybe posting a bit of what happens inside the component will shed further light.