Using function arguments in a Coldfusion thread

194 views Asked by At

How can I use function arguments in a Coldfusion thread? I do not understand why I get the following error:

Element SOMEID is undefined in ARGUMENTS.

A simplified example of my code.

public any function createSomeEntity(required numeric someId) {     
    thread action="run" name="someThread" {
        var result = someFunction(someId = arguments.someId);
        // some logic
    }
    thread action="join" name="someThread" timeout="5000";
    
    if (someThread.status != "COMPLETED") {
        // action 1
    } else {
        // action 2
    }
}       
1

There are 1 answers

3
rrk On BEST ANSWER

You need to pass the variable as attribute for to the thread, thread cannot access the argument scope.

thread
    action="run"
    name="someThread"
    someId = arguments.someId
    ^^^^^^^^^^^^^^^^^^^^^^^^^
{
    result = someFunction(someId = attributes.someId);
                                   ^^^^^^^^^^
    // some logic
}