Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Applescript FileMaker:对表引用的源进行批量更改_Applescript_Filemaker - Fatal编程技术网

Applescript FileMaker:对表引用的源进行批量更改

Applescript FileMaker:对表引用的源进行批量更改,applescript,filemaker,Applescript,Filemaker,是否有任何方法(或工具)将表引用的源从本地文件批量更改为外部源文件 情境:我管理一个托管数据库,其中有大约15个表的数百个表。我的一些用户访问数据库时互联网连接速度很慢。虽然需要为整个工作组更新许多表,但其他表上的一些数据和UI信息大多是静态的 我想复制数据库,将必须从本地文件源共享的表的表引用更改为(现有服务器的)外部源。我可以手动执行此操作,但这需要数千次单击,并且容易出错。如果我能自动化这个过程,那就更好了。(例如,指定my Sales表的所有匹配项都从本地文件移动到外部源。) 我意识到,

是否有任何方法(或工具)将表引用的源从本地文件批量更改为外部源文件

情境:我管理一个托管数据库,其中有大约15个表的数百个表。我的一些用户访问数据库时互联网连接速度很慢。虽然需要为整个工作组更新许多表,但其他表上的一些数据和UI信息大多是静态的

我想复制数据库,将必须从本地文件源共享的表的表引用更改为(现有服务器的)外部源。我可以手动执行此操作,但这需要数千次单击,并且容易出错。如果我能自动化这个过程,那就更好了。(例如,指定my Sales表的所有匹配项都从本地文件移动到外部源。)


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

到目前为止没有答案,所以我昨天写了这篇文章。它脏兮兮的,冗长的,不会出错,但它会完成任务,并且是未来的基础

--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
--要准备运行此脚本,您应该已经设置了外部数据源
--您还应该打开管理>数据库菜单并选择“关系”选项卡
--将newDataSource设置为新外部数据源的名称
将newDataSource设置为“”
--从Data Viewer中的TableNames(Get(FileName))中获取TableInstances,并将列表复制到下面的TableInstances变量中
--请注意,TableOccurrencess将是一个返回分隔的列表,设置时非常长
将表引用设置为“”
--应将哪些表从本地文件移动到托管文件的列表。请注意,这些应该是正确的表名,而不是表引用
将tablesToReplace设置为{“table1”、“table2”、…、“tableN”}
告诉应用程序“FileMaker Pro Advanced”
激活
结束语
将AppleScript的文本项分隔符设置为{return}
将j设置为表格引用的文本项数
重复上述步骤,直到j<1
告诉应用程序“系统事件”
告知应用程序流程“FileMaker Pro Advanced”
表引用的击键文本项j
使用“向下”命令敲击“o”
延迟1
将i设置为1
重复此操作直到((i>(窗口1的滚动区域1的表1的行数))或选择了窗口1的滚动区域1的表1的行i)
将i设置为i+1
结束重复
if(i)(窗口1的滚动区域1的表1的行数)
如果窗口1的滚动区域1的表1的k行的静态文本名称=currentMasterTable,则
选择窗口1滚动区域1表1的k行
将tableSelected设置为true
如果结束
将k设置为k+1
结束重复
将窗口1滚动区域1的文本字段1的值设置为currentOccurrenceName
单击窗口1的“确定”按钮
其他的
单击窗口1的“取消”按钮
如果结束
结束语
结束语
将j设置为j-1
结束重复

我再三想说“这不可能”,但我想其他人可能会想出一些办法。令人印象深刻的解决方案。