# Can I pass a value into croct.evaluate instead of hardcoding it in the query?

Asked by sam.codes on 2026-11-15. Tags: cql, evaluate, sdk.

I am calling evaluate from client code and I want to reuse one query across a
few thresholds without string-concatenating numbers into the expression:

```
croct.evaluate("user's score is greater than 90")
```

Is there a supported way to inject the threshold at call time instead of baking
it into the string

## 2 answers

### Answer from Devin Ortiz (2026-11-16)

Yes, pass them through the `attributes` option and reference them by name in
the query:

```
croct.evaluate("user's score is greater than threshold", {
  attributes: {threshold: 90}
})
```

Now the same query string covers every threshold, you just change the value
you pass. Inside CQL you can also declare values with `let` if you want to
name intermediate things for readability, but for injecting from JS the
attributes option is the clean path.

### Answer from priy_dev (2026-11-18)

Two things I would add from running these in production. Always tail it with
a fallback so a failed evaluation degrades gracefully instead of throwing:

```
croct.evaluate("user's score is greater than threshold", {
  attributes: {threshold: 90}
}).catch(() => false)
```

And keep the query compact. There is a size limit and an oversized expression
comes back as a "Too complex query" error, the
[too complex query](/answers/cql-too-complex-query-error) thread covers what
to trim. If you just want to poke at expressions while developing, the
[test an audience in the browser console](/answers/cql-test-audience-in-browser-console)
approach is handy.

#### Reply from sam.codes (2026-11-18)

The catch-to-false is a good shout, I was letting it reject. Swapped all
our calls over.
