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

Topdesk/FreeMarker流程开发:获取访客预期到达日期时出现空值评估错误求助

Troubleshooting the Null Value Error in Your Topdesk FreeMarker Workflow

Let's break down the possible causes and fixes for the null evaluation error you're seeing, even though your first step confirms the response stored successfully:

1. Mismatched Field Name (Most Likely Culprit)

Looking at your error log, it complains about _responses.GetVisitorData.body.verwachteaankomst being null—but in your validation expression, you referenced ${_responses.GetVisitorData.body.expectedArival}.

verwachteaankomst is Dutch for "expected arrival"—this means the Topdesk API returns the field under its native Dutch name, not the English expectedArival you assumed.

Fix: Update your expression to use the correct field name from the error:

${_responses.GetVisitorData.body.verwachteaankomst?string["dd MMMM yyyy"] == now?string["dd MMMM yyyy"]}

(I added ?string here to safely format the date only if the field exists—we’ll cover null handling next.)

2. Verify the Exact API Response Structure

Even with the right field name, the value might be nested deeper in the response body (e.g., under a visitor object or similar). The "stored successfully" message only confirms the response was saved, not that the field exists at the path you’re using.

Fix: Add a debug step to log the full response body so you can inspect its structure. Insert a step that outputs:

${_responses.GetVisitorData.body?string}

Check the logs to see where verwachteaankomst lives in the JSON hierarchy, then adjust your path accordingly (e.g., _responses.GetVisitorData.body.visitor.verwachteaankomst).

3. Handle Cases Where the Field Might Be Null

Some visitor records might not have an expected arrival date set at all, making the field null even if the API returns a valid response.

Fix: Use FreeMarker’s null-safe operator ?? to check for the field’s existence before comparing, and handle missing values explicitly:

<#if _responses.GetVisitorData.body.verwachteaankomst??>
  ${_responses.GetVisitorData.body.verwachteaankomst?string["dd MMMM yyyy"] == now?string["dd MMMM yyyy"]}
<#else>
  <!-- Handle missing date (e.g., return false, log a warning) -->
  false
</#if>

4. Confirm Date Formatting Locale (Post-Null Fix)

Once you resolve the null issue, watch out for locale mismatches: now?string["dd MMMM yyyy"] uses your Topdesk environment’s default locale. If the API returns dates with month names in a different language (like Dutch), the comparison might fail even if the dates are identical.

Fix: Explicitly set the locale for date formatting to match the API’s output. For Dutch locale:

${_responses.GetVisitorData.body.verwachteaankomst?string("dd MMMM yyyy", "nl_NL") == now?string("dd MMMM yyyy", "nl_NL")}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 20:38:16