无法获取变量的文本项

Can’t get text item of variable

我想从 Apple Script 中的变量中获取任务 ID。

Tyme2 遇到错误:无法获取项目 ID“2E97F048-CB5E-4F8B-8DFB-139D39BFD4C7-1285-000003A297D9D970”的任务 ID "AF7AA1C5-F10B-4CFD-97E5-9428CADC9649-1285-000007F1BAB4FE40" 的文本项 2。

尝试过的代码:

  1. set taskId to the first item of taskProject

    • 日志结果项目ID AF7AA1C5-F10B-4CFD-97E5-9428CADC9649-1285-000007F1BAB4FE40的任务id 2E97F048-CB5E-4F8B-8DFB-139D39BFD4C7-1285-000003A297D=40=97]][
  2. set taskId to text item 2 of taskProject

    • 结果:以上错误信息
  3. 通过以下方式详细说明类型: return properties of taskProject

    • 结果: {timedPlannedDuration:0.0, relatedCategoryID:"", dueDate:missing 值, class:task, mileageKilometerRate:0.0, timedRoundingMinutes:1, timedRoundingMethod:1, fixedRate:0.0, taskType:"timed", completedDate:missing 值, timedHourlyRate:0.0, completed:false, fixedQuantity:0, relatedProjectID:"2E97F048-CB5E-4F8B-8DFB-139D39BFD4C7-1285-000003A297D9D970", id:"2887FB44-D3D6-45BF-9137-00A311E47424-1210-000000DBBD0290", id:"8A9", 名称任务) ", relatedTaskID:""}

根据任务 id 的类型,如果任务 id 是文本类型,这应该可以工作(但它可能会失败,很难从你写的内容中读取 taskProject 的结构)

set taskID to ((task id of taskProject) as text)

如果它不起作用,请将此行的结果添加到问题中:

return properties of taskProject

编辑:

如果您列出属性,您始终可以通过它们的密钥访问它们。你的情况的关键是 "id"。像这样访问它:

set taskID to ((id of taskProject) as text)

set taskID to ((taskProject's id) as text)

有时keys/variable 名称会被系统保留。如果上述方法失败,请像这样尝试

set taskID to ((|id| of taskProject) as text)