You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JQL事件属性筛选查询报错:ReferenceError: type is not defined

Fixing the ReferenceError in Your JQL Query

Hey there! Let's break down what's going wrong with your query and get it working smoothly.

What's Causing the ReferenceError?

The core issue is how you're accessing the account-type property. In JavaScript (which JQL builds on), using dot notation like user.properties.account-type makes the engine interpret the hyphen as a subtraction operator. It thinks you're trying to subtract a variable named type from user.properties.account—and since type isn't defined anywhere, you get that error.

On top of that, your current filter logic has a contradiction: you're trying to find items where account-type is both "ecommerce" AND "free" at the same time, which will never return any results. You probably meant to filter for one or the other, or maybe target different properties in each check.

Corrected Query Examples

Here are two fixed versions depending on what you actually need:

Option 1: Filter for either "ecommerce" or "free" account types

function main() { 
  return Events({ from_date: "2018-01-01", to_date: "2018-03-30" })
    // Use bracket notation to safely access the hyphenated property
    .filter(function(event) { 
      const accountType = event.properties["account-type"];
      return accountType === "ecommerce" || accountType === "free";
    });
}

Option 2: Filter for user account type = "ecommerce" AND event account type = "free"

If you intended to check two different properties (user vs. event), adjust it like this:

function main() { 
  return Events({ from_date: "2018-01-01", to_date: "2018-03-30" })
    .filter(function(event) { 
      return event.user.properties["account-type"] === "ecommerce" && 
             event.properties["account-type"] === "free";
    });
}

Key Takeaways

  • Hyphenated properties: Always use bracket notation (["property-name"]) instead of dot notation when accessing properties with hyphens or special characters.
  • Logical consistency: Double-check filter conditions to avoid contradictory checks (like looking for two mutually exclusive values at once).

内容的提问来源于stack exchange,提问作者abdallahalhakim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:14:42