FileMaker:批量更改表出现的来源

发布于 2024-11-03 13:34:04 字数 355 浏览 7 评论 0原文

有没有什么方法(或者有没有任何工具)可以将表出现的来源从本地文件批量更改为外部来源文件?

情况:我管理一个托管数据库,其中包含数百个表出现次数(大约 15 个表)。我的一些用户通过缓慢的互联网连接访问数据库。虽然整个工作组的许多表都需要更新,但其他表上的一些数据和 UI 信息大多是静态的。

我想获取数据库的副本,将必须共享的表的表出现次数从本地文件源更改为外部源(现有服务器的)。我可以手动执行此操作,但这需要数千次点击并且容易出现不准确的情况。如果我可以自动化这个过程就更好了。 (例如,指定我的销售表的所有出现次数都从本地文件移动到外部源。)

我意识到,如果没有更好的方法,我也许可以使用 AppleScript 的 UI 脚本来实现这一点。

Is there any way (or are there any tools) to batch change the source of a Table Occurrence from a local file to an externally sourced file?

Situation: I manage a hosted database with hundreds of Table Occurrences of 15 or so tables. Some of my users access the database with slow internet connections. While many of the tables need to be updated for the entire workgroup, some data on other tables and UI information is mostly static.

I'd like to take a copy of the database, change the Table Occurrences of the tables which must be shared from a Local File source to an External Source (of the existing server.) I can do this by hand, but it would require thousands of clicks and be prone to inaccuracy. Much better if I can automate the process. (To specify, say, that all Occurrences of my Sales Table move from Local File to External Source.)

I realize that I might be able to so something with AppleScript's UI Scripting if there's not a better way to do it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

就像说晚安 2024-11-10 13:34:04

到目前为止还没有答案,所以我昨天写了这篇文章。它很脏、啰嗦,并且不能捕获错误,但它可以完成工作,并且是为未来构建的东西。

--to prepare to run this script, you should already have the External Data Source set up
--you should also open the Manage > Database menu and select the "Relationships" tab

--set newDataSource to the name of the new external data source
set newDataSource to "" 

--obtain tableOccurrences from TableNames ( Get ( FileName ) ) in the Data Viewer and copy the list into the tableOccurrences variable below
--note that tableOccurrences will be a return-separated list which is quite long when set
set tableOccurrences to ""

--a list of which tables should be moved from the local file to the hosted file. Note that these should be proper table names not table occurrences
set tablesToReplace to {"table1", "table2", ..., "tableN"}

tell application "FileMaker Pro Advanced"
    activate
end tell

set AppleScript's text item delimiters to {return}
set j to the number of text items of tableOccurrences

repeat until j < 1
    tell application "System Events"
        tell application Process "FileMaker Pro Advanced"
            keystroke text item j of tableOccurrences
            keystroke "o" using command down
            delay 1

            set i to 1
            repeat until ((i > (count of rows of table 1 of scroll area 1 of window 1)) or selected of row i of table 1 of scroll area 1 of window 1)
                set i to i + 1
            end repeat

            if (i <= (count of rows of table 1 of scroll area 1 of window 1) and name of static text of row i of table 1 of scroll area 1 of window 1 is in tablestoReplace) then
                set currentMasterTable to name of static text of row i of table 1 of scroll area 1 of window 1
                set currentOccurrenceName to value of text field 1 of window 1
                click pop up button 1 of window 1
                tell menu 1 of pop up button 1 of window 1
                    click menu item newDataSource
                end tell

                set k to 1
                set tableSelected to false
                repeat until tableSelected or k > (count of rows of table 1 of scroll area 1 of window 1)
                    if name of static text of row k of table 1 of scroll area 1 of window 1 = currentMasterTable then
                        select row k of table 1 of scroll area 1 of window 1
                        set tableSelected to true
                    end if
                    set k to k + 1
                end repeat

                set value of text field 1 of scroll area 1 of window 1 to currentOccurrenceName
                click button "OK" of window 1
            else
                click button "Cancel" of window 1
            end if
        end tell
    end tell
    set j to j - 1
end repeat

No answers so far, so I wrote this yesterday. It's dirty, long-winded and doesn't catch errors but it'll do the job and is something to build off of for the future.

--to prepare to run this script, you should already have the External Data Source set up
--you should also open the Manage > Database menu and select the "Relationships" tab

--set newDataSource to the name of the new external data source
set newDataSource to "" 

--obtain tableOccurrences from TableNames ( Get ( FileName ) ) in the Data Viewer and copy the list into the tableOccurrences variable below
--note that tableOccurrences will be a return-separated list which is quite long when set
set tableOccurrences to ""

--a list of which tables should be moved from the local file to the hosted file. Note that these should be proper table names not table occurrences
set tablesToReplace to {"table1", "table2", ..., "tableN"}

tell application "FileMaker Pro Advanced"
    activate
end tell

set AppleScript's text item delimiters to {return}
set j to the number of text items of tableOccurrences

repeat until j < 1
    tell application "System Events"
        tell application Process "FileMaker Pro Advanced"
            keystroke text item j of tableOccurrences
            keystroke "o" using command down
            delay 1

            set i to 1
            repeat until ((i > (count of rows of table 1 of scroll area 1 of window 1)) or selected of row i of table 1 of scroll area 1 of window 1)
                set i to i + 1
            end repeat

            if (i <= (count of rows of table 1 of scroll area 1 of window 1) and name of static text of row i of table 1 of scroll area 1 of window 1 is in tablestoReplace) then
                set currentMasterTable to name of static text of row i of table 1 of scroll area 1 of window 1
                set currentOccurrenceName to value of text field 1 of window 1
                click pop up button 1 of window 1
                tell menu 1 of pop up button 1 of window 1
                    click menu item newDataSource
                end tell

                set k to 1
                set tableSelected to false
                repeat until tableSelected or k > (count of rows of table 1 of scroll area 1 of window 1)
                    if name of static text of row k of table 1 of scroll area 1 of window 1 = currentMasterTable then
                        select row k of table 1 of scroll area 1 of window 1
                        set tableSelected to true
                    end if
                    set k to k + 1
                end repeat

                set value of text field 1 of scroll area 1 of window 1 to currentOccurrenceName
                click button "OK" of window 1
            else
                click button "Cancel" of window 1
            end if
        end tell
    end tell
    set j to j - 1
end repeat
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文