如何使用 FileMaker Pro 脚本将 FMrecord 添加为 MacOS 日历中的日历事件?

How can I Use a FileMaker Pro script to add a FMrecord as a calendar event in MacOS- calendar?

提问人:harold 提问时间:9/22/2023 最后编辑:CausingUnderflowsEverywhereharold 更新时间:10/1/2023 访问量:54

问:

这是我在运行脚本时返回的错误/消息

item1 of {title:"& $Title &",startDate:"& $StartDate &"....} cannot be requested. Unknown error: -1728

似乎是我的 FMscriptParams 列表无法与 Applescript 通信的问题。

有没有人有解决方案来让脚本工作。 我未来的目标是让 Calendar(MacOS) 和 FilemakerRecord 同步。如果我更新记录,让它更改 CalendarEvent,如果我更改 CalendarEvent,让它更改记录。

这是我正在使用的 Filemaker 脚本

Set variable [ $Title; Value:"Customer" & Log::X & Customers::CustomerID letters ] 
Set variable [ $StartDate; Value:Log::Date of project start duration ] 
Set variable [ $EndDate; Value:Log::Project end date or end of duration ] 
Set variable [ $Location; Value:Log::Location ] 
Set variable [ $Description; Value:Log::Description ] 

这是我正在使用的原生 AppleScript

Run AppleScript [ Native AppleScript:
-- Get FileMaker script parameters 
set fmScriptParams to {title: "& $Title &", startDate: "& $StartDate &", endDate: "& $EndDate &"} 
tell application "FileMaker Pro Advanced" set scriptParams to fmScriptParams

-- Get the list of FileMaker repeat script parameters with i from 1 to count of scriptParams 
set end of fmScriptParams to item i of scriptParams end repeat end tell 

-- Assign the script parameters to AppleScript variables 
set eventTitle to item 1 of fmScriptParams 
set startDate to item 2 of fmScriptParams 
set endDate to item 3 of fmScriptParams 
set eventLocation to item 4 of fmScriptParams 
set eventDescription to item 5 of fmScriptParams

-- Then perform actions with the assigned variables 
-- For example, here you can display the values of the variables display dialog "Event Title: "& eventTitle & return & ¬ "Start Date: "& startDate & return & ¬ "End Date: "& endDate & return & ¬ "Location: "& eventLocation & return & ¬ "Description: "& eventDescription 

-- Find the iCloud calendar by name 
set iCloudCalendarName to "FM" 

-- The name of your iCloud calendar 
-- Add the appointment to the iCloud calendar 
tell application "Calendar" set iCloudCalendar to calendar iCloudCalendarName 
set newEvent to make new event at iCloudCalendar with properties ¬ {summary:eventTitle, start date:startDate, end date:endDate, location:eventLocation, description:eventDescription} tell newEvent 

-- You can set additional properties if necessary, such as notifications, participants, etc. 
end tell activate 
end tell ]
macOS AppleScript iCalendar FileMaker

评论

1赞 michael.hor257k 9/22/2023
Stack Overflow 是英文的。请努力发布您的代码的英文版本(FM 和 AS)。否则,就没有多少人(如果有的话)可以重现问题并确定原因。另外,请正确格式化您的代码;现在,不可能将注释与实际代码分开。

答:

0赞 michael.hor257k 10/1/2023 #1

您不能在本机 AppleScript 中使用 FileMaker 变量和计算。使用 AppleScript 获取字段值,或者选择该选项并在其中构造 AppleScript 的文本。Calculated AppleScript

(您可能会遇到将 FileMaker 的日期转换为 AppleScript 的日期的问题。如果是这样,请就此单独提出问题。