Roman Kharitonov
Roman Kharitonov

Reputation: 141

Using function arguments in a Coldfusion thread

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
    }
}       

Upvotes: 4

Views: 241

Answers (1)

rrk
rrk

Reputation: 15846

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
}

Upvotes: 7

Related Questions